9. References: Typing Mutable References
Up to this point, we have considered a variety of pure language features, including functional abstraction, basic types such as numbers and booleans, and structured types such as records and variants. These features form the backbone of most programming languages — including purely functional languages such as Haskell and "mostly functional" languages such as ML, as well as imperative languages such as C and object-oriented languages such as Java, C#, and Scala.
Most practical languages also include various impure features that cannot be described in the simple semantic framework we have used so far. In particular, besides just yielding results, computation in these languages may assign to mutable variables (reference cells, arrays, mutable record fields, etc.); perform input and output to files, displays, or network connections; make non-local transfers of control via exceptions, jumps, or continuations; engage in inter-process synchronization and communication; and so on. In the literature on programming languages, such "side effects" of computation are collectively referred to as computational effects.
In this chapter, we'll see how one sort of computational effect — mutable references — can be added to the calculi we have studied. The main extension will be dealing explicitly with a store (or heap) and pointers that name store locations. This extension is fairly straightforward to define; the most interesting part is the refinement we need to make to the statement of the type preservation theorem.
9.1. Definitions
Pretty much every programming language provides some form of assignment operation that changes the contents of a previously allocated piece of storage. (Lean is a rare exception!)
In some languages — notably ML and its relatives — the
mechanisms for name binding and those for assignment are kept
separate. We can have a variable x whose value is the number
5, or we can have a variable y whose value is a
reference (or pointer) to a mutable cell whose current
contents is 5. These are different things, and the difference
is visible to the programmer. We can add x to another number,
but not assign to it. We can use y to assign a new value to the
cell that it points to (by writing y:=84), but we cannot use y
directly as an argument to an operation like +. Instead, we
must explicitly dereference it, writing !y to obtain its
current contents.
In most other languages — in particular, in all members of the C family, including Java — every variable name refers to a mutable cell, and the operation of dereferencing a variable to obtain its current contents is implicit.
For purposes of formal study, it is useful to keep these mechanisms separate. The development in this chapter will closely follow ML's model. Applying the lessons learned here to C-like languages is a straightforward matter of collapsing some distinctions and rendering some operations such as dereferencing implicit instead of explicit.
9.1.1. Syntax
In this chapter, we study adding mutable references to the simply-typed lambda calculus with natural numbers.
namespace STLCRef
open scoped MyGetElem
The basic operations on references are allocation, dereferencing, and assignment.
-
To allocate a reference, we use the
refoperator, providing an initial value for the new cell.For example,
ref 5creates a new cell containing the value5and reduces to a reference to that cell. -
To read the current value of this cell, we use the dereferencing operator
!.For example,
!(ref 5)reduces to5. -
To change the value stored in a cell, we use the assignment operator.
If
ris a reference,r := 7will store the value7in the cell referenced byr.
9.1.2. Types
We start with the simply typed lambda calculus over the natural numbers. Besides the base natural-number type and arrow types, we add two more types to deal with references. First, we need the unit type, which we will use as the result type of an assignment operation. We then add reference types.
If τ is a type, then Ref τ is the type of references to
cells holding values of type τ.
| τ | ::= | Nat | |
| | | Unit | ||
| | | τ → τ | ||
| | | Ref τ |
inductive Ty : Type :=
| nat : Ty
| unit : Ty
| arrow : Ty → Ty → Ty
| ref : Ty → Ty
9.1.3. Terms
Besides the usual variables, abstractions, applications,
terms related to natural numbers, and unit, we need four
more sorts of terms to handle mutable references:
| t | ::= | ref t | (reference) |
| | | ! t | (dereference) | |
| | | t := t | (assignment) | |
| | | l | (location) |
inductive Tm : Type :=
-- STLC with numbers:
| var : String → Tm
| app : Tm → Tm → Tm
| abs : String → Ty → Tm → Tm
| const : Nat → Tm
| succ : Tm → Tm
| pred : Tm → Tm
| mult : Tm → Tm → Tm
| ite0 : Tm → Tm → Tm → Tm
-- New terms:
| unit : Tm
| ref : Tm → Tm
| deref : Tm → Tm
| assign : Tm → Tm → Tm
| loc : Nat → Tm
Notation
scoped syntax:max num : stlcTm
scoped syntax:60 stlcTm:60 " * " stlcTm:61 : stlcTm
scoped syntax:50 "if0 " stlcTm:51 " then " stlcTm:50 " else " stlcTm:50 : stlcTm
scoped syntax:60 stlcTm:60 " := " stlcTm:61 : stlcTm
scoped syntax:60 "Ref " stlcTy:61 : stlcTy
scoped syntax:60 "ref " stlcTm:61 : stlcTm
scoped syntax:60 "loc " stlcTm:61 : stlcTm
scoped syntax:60 "!" stlcTm:61 : stlcTm
scoped syntax:55 stlcTm:56 " ; " stlcTm:55 : stlcTm
scoped syntax stlcCtx " / " term:max " ⊢ " stlcTm " ⦂ " stlcTy : stlcQuoted
abbrev Tm.tseq t₁ t₂ :=
Tm.app (.abs "X" .unit t₂) t₁
namespace Elab
open StlcCommon
open Lean Meta Elab Term
def language : Language where
tyType := ``Ty
tmType := ``Tm
arrowCtor := ``Ty.arrow
varCtor := ``Tm.var
appCtor := ``Tm.app
absCtor := ``Tm.abs
-- defined later
subst := `STLCRef.subst
hasType := `STLCRef.HasType
def extendedTyHandler : TyElabHandler :=
fun recur k T => do
match T with
| `(stlcTy| Nat) =>
return mkConst ``Ty.nat
| `(stlcTy| Unit) =>
return mkConst ``Ty.unit
| `(stlcTy| Ref $τ:stlcTy) => do
let τ ← recur τ
return mkApp (mkConst ``Ty.ref) τ
| _ => k T
def tyHandlers : TyElabHandler :=
extendedTyHandler.orElse (commonTyHandler language)
partial def elabTy : TyElab :=
tyHandlers elabTy <| unsupportedTy language
def extendedTmHandler : TmElabHandler :=
fun recur k Γ free t => do
match t with
| `(stlcTm| $n:num) => do
return (mkApp (mkConst ``Tm.const) (mkNatLit n.getNat), free )
| `(stlcTm| Nat) => do
throwError "`Nat` is not a valid term."
| `(stlcTm| succ $t:stlcTm) => do
let (t, free) ← recur Γ free t
return (mkApp (mkConst ``Tm.succ) t, free)
| `(stlcTm| pred $t:stlcTm) => do
let (t, free) ← recur Γ free t
return (mkApp (mkConst ``Tm.pred) t, free)
| `(stlcTm| $t₁:stlcTm * $t₂:stlcTm) => do
let (t₁, free) ← recur Γ free t₁
let (t₂, free) ← recur Γ free t₂
return (mkApp2 (mkConst ``Tm.mult) t₁ t₂, free)
| `(stlcTm| if0 $c:stlcTm then $t:stlcTm else $e:stlcTm) => do
let (c, free) ← recur Γ free c
let (t, free) ← recur Γ free t
let (e, free) ← recur Γ free e
return (mkApp3 (mkConst ``Tm.ite0) c t e, free)
| `(stlcTm| Unit) => do
throwError "`Unit` is not a valid term."
| `(stlcTm| unit) => do
return (mkConst ``Tm.unit, free)
| `(stlcTm| ref $t:stlcTm) => do
let (t, free) ← recur Γ free t
return (mkApp (mkConst ``Tm.ref) t, free)
| `(stlcTm| !$t:stlcTm) => do
let (t, free) ← recur Γ free t
return (mkApp (mkConst ``Tm.deref) t, free)
| `(stlcTm| loc $n:num) => do
return (mkApp (mkConst ``Tm.loc) (mkNatLit n.getNat), free )
| `(stlcTm| $t₁:stlcTm := $t₂:stlcTm) => do
let (t₁, free) ← recur Γ free t₁
let (t₂, free) ← recur Γ free t₂
return (mkApp2 (mkConst ``Tm.assign) t₁ t₂, free)
| `(stlcTm| $t₁:stlcTm ; $t₂:stlcTm) => do
let (t₁, free) ← recur Γ free t₁
let (t₂, free) ← recur Γ free t₂
return (mkApp2 (mkConst ``Tm.tseq) t₁ t₂, free)
| _ => k Γ free t
def tmHandlers : TmElabHandler :=
extendedTmHandler.orElse (commonTmHandler language elabTy)
partial def elabTm : TmElab :=
tmHandlers elabTm unsupportedTm
def elabCtx : CtxElab := elabCtxCommon language elabTy
-- `HasType` takes the store typing as an extra first argument,
-- so we build typing judgments here instead of in `elabQuoted`.
def mkHasType (δ Γ t T : Expr) : TermElabM Expr := do
let some hasType ← resolveId? (mkIdent language.hasType)
| throwError "unknown declaration `{language.hasType}`"
return mkApp4 hasType δ Γ t T
@[scoped term_elab StlcCommon.bracket]
def elabBracket : TermElab :=
fun stx expectedType? => do
match stx with
| `(<{ $Γ:stlcCtx / $δ:term ⊢ $t:stlcTm ⦂ $T:stlcTy }>) => do
let (Γ, scope) ← elabCtx Γ
let (t, _) ← elabTm scope [] t
let T ← elabTy T
let δ ← elabTermEnsuringType δ (mkApp (mkConst ``List [levelZero]) (mkConst ``Ty))
mkHasType δ Γ t T
| `(<{ $_:stlcCtx ⊢ $_:stlcTm ⦂ $_:stlcTy }>) =>
throwError "typing judgments need a store typing: write `Γ / δ ⊢ t ⦂ τ`"
| `(<{ $q:stlcQuoted }>) =>
elabQuoted language elabTy elabTm elabCtx q expectedType?
| _ => throwUnsupportedSyntax
end Elab
open scoped Elab
namespace Delab
open StlcCommon Elab Delab
open Lean PrettyPrinter Delaborator
@[app_unexpander Ty.nat]
private def Ty.unexpandNat : Unexpander
| stx => do
let Nat := mkObjectIdentFrom stx "Nat"
let T ← `(stlcTy| $Nat:ident)
`(<{ $T:stlcTy }>)
@[app_unexpander Ty.unit]
private def Ty.unexpandUnit : Unexpander
| stx => do
let Unit := mkObjectIdentFrom stx "Unit"
let T ← `(stlcTy| $Unit:ident)
`(<{ $T:stlcTy }>)
@[app_unexpander Ty.arrow]
private def Ty.unexpandArrow : Unexpander := Delab.unexpandArrow
@[app_unexpander Ty.ref]
private def Ty.unexpandRef : Unexpander
| `($_ $T) => do
let T' := getTy T
`(<{ Ref $T':stlcTy }>)
| _ => throw ()
private def reservedNames : String → Bool
| "Nat" | "Unit" | "succ" | "pred"
| "if0" | "ref" | "loc" | "Ref"
| "unit" => true
| _ => false
@[app_unexpander Tm.var]
private def Tm.unexpandVar : Unexpander := Delab.unexpandVar reservedNames ``Tm.var
@[app_delab Tm.var]
private def Tm.delabVar : Delab := Delab.delabVar ``Tm.var
@[app_unexpander Tm.app]
private def Tm.unexpandApp : Unexpander := Delab.unexpandApp
@[app_unexpander Tm.abs]
private def Tm.unexpandAbs : Unexpander := Delab.unexpandAbs
@[app_unexpander Tm.const]
private def Tm.unexpandConst : Unexpander
| `($_ $n:num) => `(<{ $n:num }>)
| _ => throw ()
@[app_unexpander Tm.succ]
private def Tm.unexpandSucc : Unexpander
| stx@`($_ $t) => do
let succ := mkObjectIdentFrom stx "succ"
let t' := getTm t
`(<{ $succ:ident $t':stlcTm }>)
| _ => throw ()
@[app_unexpander Tm.pred]
private def Tm.unexpandPred : Unexpander
| stx@`($_ $t) => do
let pred := mkObjectIdentFrom stx "pred"
let t' := getTm t
`(<{ $pred:ident $t':stlcTm }>)
| _ => throw ()
@[app_unexpander Tm.mult]
private def Tm.unexpandMult : Unexpander
| `($_ $t₁ $t₂) => do
let t₁' := getTm t₁
let t₂' := getTm t₂
`(<{ $t₁':stlcTm * $t₂':stlcTm }>)
| _ => throw ()
@[app_unexpander Tm.tseq]
private def Tm.unexpandTseq : Unexpander
| `($_ $t₁ $t₂) => do
let t₁' := getTm t₁
let t₂' := getTm t₂
`(<{ $t₁':stlcTm ; $t₂':stlcTm }>)
| _ => throw ()
@[app_unexpander Tm.ite0]
private def Tm.unexpandIte0 : Unexpander
| `($_ $c $t $e) => do
let c' := getTm c
let t' := getTm t
let e' := getTm e
`(<{ if0 $c':stlcTm then $t':stlcTm else $e':stlcTm }>)
| _ => throw ()
@[app_unexpander Tm.unit]
private def Tm.unexpandUnit : Unexpander
| stx => do
let unit := mkObjectIdentFrom stx "unit"
let t ← `(stlcTm| $unit:ident)
`(<{ $t:stlcTm }>)
@[app_unexpander Tm.assign]
private def Tm.unexpandAssign : Unexpander
| `($_ $t₁ $t₂) => do
let t₁' := getTm t₁
let t₂' := getTm t₂
`(<{ $t₁':stlcTm := $t₂':stlcTm }>)
| _ => throw ()
@[app_unexpander Tm.ref]
private def Tm.unexpandRef : Unexpander
| `($_ $t₁) => do
let t₁' := getTm t₁
`(<{ ref $t₁':stlcTm }>)
| _ => throw ()
@[app_unexpander Tm.deref]
private def Tm.unexpandDeref : Unexpander
| `($_ $t₁) => do
let t₁' := getTm t₁
`(<{ !$t₁':stlcTm }>)
| _ => throw ()
@[app_unexpander Tm.loc]
private def Tm.unexpandLoc : Unexpander
| `($_ $n:num) => `(<{ loc $n:num }>)
| _ => throw ()
end Delab
Intuitively:
-
ref t(formally,ref t) allocates a new reference cell with the valueτand reduces to the location of the newly allocated cell; -
!t(formally,deref t) reduces to the contents of the cell referenced byτ; -
t₁ := t₂(formally,assign t₁ t₂) assignst₂to the cell referenced byt₁; and -
l(formally,loc l) is a reference to the cell at locationl. We'll discuss locations later.
In informal examples, we'll also freely use the extensions of the STLC developed in the MoreStlc chapter; however, to keep the proofs small, we won't bother formalizing them again here. (It would be easy to do so, since there are no very interesting interactions between those features and references.)
9.1.4. Typing (Preview)
Informally, the typing rules for allocation, dereferencing, and assignment look roughly like this:
Γ ⊢ t₁ ⦂ τ₁
--------------------- (ref)
Γ ⊢ ref t₁ ⦂ Ref τ₁
Γ ⊢ t₁ ⦂ Ref τ₁
--------------------- (deref)
Γ ⊢ !t₁ ⦂ τ₁
Γ ⊢ t₁ ⦂ Ref τ₂
Γ ⊢ t₂ ⦂ τ₂
--------------------- (assign)
Γ ⊢ t₁ := t₂ ⦂ Unit
The rule for locations will require a bit more machinery, and this will motivate some changes to the other rules; we'll come back to this later.
9.1.5. Values and Substitution
Besides abstractions, numbers, and the unit value, we have one new type of value: locations.
A location is a concrete pointer value — think of it like an address
in memory. Locations should never be written directly by programmers;
they are used to keep track of the intermediate states of programs
involving references. In particular, the result of a ref expression
is a location.
inductive Tm.IsValue : Tm → Prop :=
| abs : forall x τ₂ t₁,
IsValue <{λx : τ₂. t₁}>
| nat : forall (n : Nat),
IsValue (.const n)
| unit :
IsValue <{ unit }>
| loc_ : forall (l : Nat),
IsValue (.loc l)
attribute [StlcRefEval] Tm.IsValue.abs Tm.IsValue.nat Tm.IsValue.unit Tm.IsValue.loc_
Extending substitution to handle the new syntax of terms is straightforward: substituting into a pointer leaves it unchanged.
def subst (x : String) (s : Tm) (t : Tm) : Tm :=
match t with
-- pure STLC
| .var y =>
if x = y then s else t
| .abs y τ t₁ =>
if x = y then t else <{ λ y : τ . [x := s] t₁ }>
| .app t₁ t₂ =>
<{ ([x := s] t₁) ([x := s] t₂) }>
-- numbers
| .const _ =>
t
| .succ t₁ =>
<{ succ ([x := s] t₁) }>
| .pred t₁ =>
<{ pred ([x := s] t₁) }>
| .mult t₁ t₂ =>
<{ ([x := s] t₁) * ([x := s] t₂) }>
| .ite0 t₁ t₂ t₃ =>
<{
if0 [x := s] t₁
then [x := s] t₂
else [x := s] t₃
}>
-- unit
| .unit => <{ unit }>
-- references
| .ref t₁ => <{ ref ([x := s] t₁) }>
| .deref t₁ => <{ !([x := s] t₁) }>
| .loc n => .loc n
| .assign t₁ t₂ =>
<{ ([x := s] t₁) := ([x := s] t₂) }>
Notation encoding
open Lean PrettyPrinter in
@[app_unexpander subst]
def unexpandSubst : Unexpander := StlcCommon.Delab.unexpandSubst
9.2. Pragmatics
9.2.1. Side Effects and Sequencing
The fact that we've chosen the result of an assignment
expression to be the trivial value unit allows a nice
abbreviation for sequencing. For example, we can write
R:=succ(!R); !R
as an abbreviation for
(λX:Unit, !R) (R:=succ(!R))
This has the effect of reducing two expressions in order and
returning the value of the second. Restricting the type of the
first expression to Unit helps the typechecker to catch some
silly errors by permitting us to throw away the first value only
if it is really guaranteed to be trivial.
Notice that, if the second expression is also an assignment, then
the type of the whole sequence will be Unit, so we can validly
place it to the left of another ; to build longer sequences of
assignments:
R:=succ(!R); R:=succ(!R); R:=succ(!R); R:=succ(!R); !R
Formally, we introduce sequencing as a derived form
tseq that expands into an abstraction and an application.
/-- info: <{ R := succ (!R) ; !R }> : Tm -/
#guard_msgs in
#check <{R := succ (!R); !R}>
9.2.2. References and Aliasing
It is important to bear in mind the difference between the
reference that is bound to some variable r and the cell
in the store that is pointed to by this reference.
If we make a copy of r, for example by binding its value to
another variable s, what gets copied is only the reference,
not the contents of the cell itself.
For example, after reducing
let R = ref 5 in
let S = R in
S := 82;
(!R)+1
the cell referenced by R will contain the value 82, while the
result of the whole expression will be 83. The references R
and S are said to be aliases for the same cell.
The possibility of aliasing can make programs with references quite tricky to reason about. For example, the expression
R := 5; R := !S
assigns 5 to R and then immediately overwrites it with S's
current value; this has exactly the same effect as the single
assignment
R := !S
unless we happen to do it in a context where R and S are
aliases for the same cell!
let R = ref 0 in
let S = R in
R := 5; R := !S
9.2.3. Shared State
Of course, aliasing is also a large part of what makes references useful. In particular, it allows us to set up "implicit communication channels" — shared state — between different parts of a program. For example, suppose we define a reference cell and two functions that manipulate its contents:
let C = ref 0 in
let Incc = λ_:Unit. (C := succ (!C); !C) in
let Decc = λ_:Unit. (C := pred (!C); !C) in
...
Note that, since their argument types are Unit, the
arguments to the abstractions in the definitions of Incc and
Decc are not providing any useful information to the bodies of
these functions (using the wildcard _ as the name of the bound
variable is a reminder of this). Instead, the purpose of these
abstractions is to "slow down" the execution of the function
bodies. Since function abstractions are values, the two lets are
executed simply by binding these functions to the names Incc and
Decc, rather than by actually incrementing or decrementing C.
Later, each call to one of these functions results in its body
being executed once and performing the appropriate mutation on
C. Such functions are often called thunks.
In the context of these declarations, calling Incc results in
changes to C that can be observed by calling Decc. For
example, if we replace the ... with (Incc unit; Incc unit; Decc
unit), the result of the whole program will be 1.
9.2.4. Objects
We can go a step further and write a function that creates C,
Incc, and Decc, packages Incc and Decc together into a
record, and returns this record:
Newcounter =
λ_:Unit.
let C = ref 0 in
let Incc = λ_:Unit. (C := succ (!C); !C) in
let Decc = λ_:Unit. (C := pred (!C); !C) in
{i=Incc, d=Decc}
Now, each time we call Newcounter, we get a new record of
functions that share access to the same storage cell C. The
caller of Newcounter can't get at this storage cell directly,
but can affect it indirectly by calling the two functions. In
other words, we've created a simple form of object.
let C₁ = newcounter unit in let C₂ = newcounter unit in // we've allocated two separate storage cells now! let R₁ = C₁.i unit in let R₂ = C₂.i unit in R₂ // yields 1, not 2!
Draw (on paper) the contents of the store at the point in
execution where the first two lets have finished and the third
one is about to begin.
9.2.5. References to Compound Types
A reference cell need not contain just a number: the primitives we've defined above allow us to create references to values of any type, including functions. For example, we can use references to functions to give a(n inefficient) implementation of arrays of numbers as follows.
Write NatArray for the type Ref (Nat→Nat).
Recall the Equal function from the MoreStlc chapter:
Equal =
fix
(λEq:Nat→Nat→Bool.
λM:Nat. λN:Nat.
if M=0 then iszero n
else if N=0 then false
else Eq (pred m) (pred n))
To build a new array, we allocate a reference cell and fill
it with a function that, when given an index, always returns 0.
Newarray = λ_:Unit. ref (λN:Nat.0)
To look up an element of an array, we apply the function to the desired index.
Lookup = λA:NatArray, λN:Nat. (!A) N
The interesting part of the encoding is the Update function. It
takes an array, an index, and a new value to be stored at that index, and
it does its job by creating (and storing in the reference) a new function
that, when it is asked for the value at this very index, returns the new
value that was given to Update, while on all other indices it passes the
lookup to the function that was previously stored in the reference.
Update = \A:NatArray, \M:Nat, \V:Nat, let Oldf = !A in A := (λN:Nat. if Equal M N then V else Oldf N);
References to values containing other references can also be very useful, allowing us to define data structures such as mutable lists and trees.
If we defined Update more compactly like this
Update = \A:NatArray, \M:Nat, \V:Nat,
A := (λN:Nat. if Equal M N then V else (!A) N);
would it behave the same?
No: calls to Lookup with any index other than the one given to
Update will now diverge. The point is that we need to make sure
we look up the value stored in A before we overwrite it with
the new function. Otherwise, when we get around to doing the
lookup, we will find the new function, not the original one.
9.2.6. Null References
There is one final significant difference between our
references and C-style mutable variables: in C-like languages,
variables holding pointers into the heap may sometimes have the
value NULL. Dereferencing such a "null pointer" is an error,
and results either in a clean exception (Java and C#) or in
arbitrary and possibly insecure behavior (C and relatives like
C++). Null pointers cause significant trouble in C-like
languages: the fact that any pointer might be null means that any
dereference operation in the program can potentially fail.
Even in ML-like languages, there are sometimes situations where we may or may not have a valid pointer in our hands. Fortunately, there is no need to extend the basic mechanisms of references to represent such situations: the sum types introduced in the MoreStlc chapter already give us what we need.
First, we can use sums to build an analog of the option types
introduced in the Lists chapter of Logical Foundations.
Define Option τ to be an abbreviation for Unit + τ.
Then a "nullable reference to a τ" is simply an element of the
type Option (Ref τ).
9.2.7. Garbage Collection
A last issue that we should mention before we move on with formalizing references is storage de-allocation. We have not provided any primitives for freeing reference cells when they are no longer needed. Instead, like many modern languages (including OCaml, Haskell, Java, etc.), we rely on the run-time system to perform garbage collection, automatically identifying and reusing cells that can no longer be reached by the program.
This is not just a question of taste in language design: it is extremely difficult to achieve type safety in the presence of an explicit deallocation operation.
One reason for this is the familiar dangling reference problem:
we allocate a cell holding a number, save a reference to it in
some data structure, use it for a while, then deallocate it and
allocate a new cell holding a boolean, possibly reusing the same
storage. Now we can have two names for the same storage cell —
one with type Ref Nat and the other with type Ref Bool.
Show how this can lead to a violation of type safety.
Suppose the language provides a primitive free that takes a
reference cell as argument and releases its storage so that (say)
the very next allocation of a reference cell will obtain the same
piece of memory. Then the program
let R = ref 0 in
let S = R in
free R;
let T = ref true in
T := false;
succ (!S)
will reduce to the stuck term succ false. Note that aliasing
plays a crucial role here in setting up the problem, since it
prevents us from detecting invalid deallocations by simply making
free r illegal if the variable R appears free in the remainder
of the expression.
This sort of example is easy to mimic in a language like C with
manual memory management (our ref constructor corresponds to C's
malloc, our free to a simplified version of C's free).
9.3. Operational Semantics
9.3.1. Locations
The most subtle aspect of the treatment of references
appears when we consider how to formalize their operational
behavior. One way to see why is to ask, "What should be the
values of type Ref τ?" The crucial observation that we need
to take into account is that reducing a ref operator should
do something — namely, allocate some storage — and the result
of the operation should be a reference to this storage.
What, then, is a reference?
The run-time store in most programming-language implementations is
essentially just a big array of bytes. The run-time system keeps
track of which parts of this array are currently in use. When we
need to allocate a new reference cell, we allocate a large enough
segment from the free region of the store (4 bytes for integer
cells, 8 bytes for cells storing Floats, etc.), record somewhere
that it is being used, and return the index (typically, a 32- or
64-bit integer) of the start of the newly allocated region. These
indices are references.
For present purposes, there is no need to be quite so concrete. We can think of the store as an array of values, rather than an array of bytes, abstracting away from the different sizes of the run-time representations of different values. A reference, then, is simply an index into the store. (If we like, we can even abstract away from the fact that these indices are numbers, but for purposes of formalization in Lean it is convenient to use numbers.) We use the word location instead of reference or pointer to emphasize this abstract quality.
Treating locations abstractly in this way will prevent us from
modeling the pointer arithmetic found in low-level languages
such as C. This limitation is intentional. While pointer
arithmetic is occasionally very useful, especially for
implementing low-level services such as garbage collectors, it
cannot be tracked by most type systems: knowing that location n
in the store contains a Float doesn't tell us anything useful
about the type of location n+4. In C, pointer arithmetic is a
notorious source of type-safety violations.
9.3.2. Stores
Recall that, in the small-step operational semantics for Imp, the step relation needed to carry along an auxiliary state in addition to the program being executed. In the same way, once we have added reference cells to the STLC, our step relation must carry along a store to keep track of the contents of reference cells.
We could re-use the same functional representation we used for
states in Imp, but for carrying out the proofs in this chapter it
is actually more convenient to represent a store simply as a
list of values. (The reason we didn't use this representation
before is that, in Imp, a program could modify any location at any
time, so states had to be ready to map any variable to a value.
However, in the STLC with references, the only way to create a
reference cell is with ref t₁, which puts the value of t₁
in a new reference cell and reduces to the location of the newly
created reference cell. When reducing such an expression, we can
just add a new reference cell to the end of the list representing
the store.)
abbrev Store := List Tm
We use ρ[n] to retrieve the value of the reference
cell at location n in the store ρ. Note that we must give a
default value to nth in case we try looking up an index which is
too large. (In fact, we never actually do this, but proving
that we don't will require a bit of work.)
open scoped MyGetElem
instance : MyGetElem Store Nat Tm where
getElem ρ n := ρ.getD n <{unit}>
@[simp]
theorem Store_get_succ_tl (hd : Tm) (tl : Store) (n : Nat) :
(hd :: tl)[n + 1] = tl[n] := hd:Tmtl:Storen:Nat⊢ (hd :: tl)[n + 1] = tl[n] All goals completed! 🐙
@[simp]
theorem Store_get_zero_hd (hd : Tm) (tl : Store) :
(hd :: tl)[0] = hd := hd:Tmtl:Store⊢ (hd :: tl)[0] = hd All goals completed! 🐙
To update the store, we use the List.set function, which replaces
the contents of a cell at a particular index.
def List.set : (l : List α) → (n : Nat) → (a : α) → List α
| cons _ as, 0, b => cons b as
| cons a as, Nat.succ n, b => cons a (set as n b)
| nil, _, _ => nil
As might be expected, we will also need some technical lemmas; they are straightforward to prove.
theorem Store_get_set_eq (ρ : Store) (l : Nat) (x : Tm)
(h : l < ρ.length) :
(ρ.set l x)[l] = x := ρ:Storel:Natx:Tmh:l < List.length ρ⊢ (List.set ρ l x)[l] = x
induction ρ generalizing l with
x:Tml:Nath:l < [].length⊢ ([].set l x)[l] = x All goals completed! 🐙
x:Tmhd:Tmtl:List Tmih:∀ (l : Nat), l < tl.length → (tl.set l x)[l] = xl:Nath:l < (hd :: tl).length⊢ ((hd :: tl).set l x)[l] = x x:Tmhd:Tmtl:List Tmih:∀ (l : Nat), l < tl.length → (tl.set l x)[l] = xh:0 < (hd :: tl).length⊢ ((hd :: tl).set 0 x)[0] = xx:Tmhd:Tmtl:List Tmih:∀ (l : Nat), l < tl.length → (tl.set l x)[l] = xn✝:Nath:n✝ + 1 < (hd :: tl).length⊢ ((hd :: tl).set (n✝ + 1) x)[n✝ + 1] = x x:Tmhd:Tmtl:List Tmih:∀ (l : Nat), l < tl.length → (tl.set l x)[l] = xh:0 < (hd :: tl).length⊢ ((hd :: tl).set 0 x)[0] = xx:Tmhd:Tmtl:List Tmih:∀ (l : Nat), l < tl.length → (tl.set l x)[l] = xn✝:Nath:n✝ + 1 < (hd :: tl).length⊢ ((hd :: tl).set (n✝ + 1) x)[n✝ + 1] = x All goals completed! 🐙
theorem Store_get_set_neq (l₁ l₂ : Nat) (t : Tm) (ρ : Store) :
l₁ ≠ l₂ ->
(ρ.set l₂ t)[l₁] = ρ[l₁] := l₁:Natl₂:Natt:Tmρ:Store⊢ l₁ ≠ l₂ → (List.set ρ l₂ t)[l₁] = ρ[l₁]
induction ρ generalizing l₁ l₂ with
t:Tml₁:Natl₂:Nat⊢ l₁ ≠ l₂ → ([].set l₂ t)[l₁] = [][l₁] All goals completed! 🐙
t:Tmhd:Tmtl:List Tmih:∀ (l₁ l₂ : Nat), l₁ ≠ l₂ → (tl.set l₂ t)[l₁] = tl[l₁]l₁:Natl₂:Nat⊢ l₁ ≠ l₂ → ((hd :: tl).set l₂ t)[l₁] = (hd :: tl)[l₁] t:Tmhd:Tmtl:List Tmih:∀ (l₁ l₂ : Nat), l₁ ≠ l₂ → (tl.set l₂ t)[l₁] = tl[l₁]l₂:Nat⊢ 0 ≠ l₂ → ((hd :: tl).set l₂ t)[0] = (hd :: tl)[0]t:Tmhd:Tmtl:List Tmih:∀ (l₁ l₂ : Nat), l₁ ≠ l₂ → (tl.set l₂ t)[l₁] = tl[l₁]l₂:Natn✝:Nat⊢ n✝ + 1 ≠ l₂ → ((hd :: tl).set l₂ t)[n✝ + 1] = (hd :: tl)[n✝ + 1] t:Tmhd:Tmtl:List Tmih:∀ (l₁ l₂ : Nat), l₁ ≠ l₂ → (tl.set l₂ t)[l₁] = tl[l₁]l₂:Nat⊢ 0 ≠ l₂ → ((hd :: tl).set l₂ t)[0] = (hd :: tl)[0]t:Tmhd:Tmtl:List Tmih:∀ (l₁ l₂ : Nat), l₁ ≠ l₂ → (tl.set l₂ t)[l₁] = tl[l₁]l₂:Natn✝:Nat⊢ n✝ + 1 ≠ l₂ → ((hd :: tl).set l₂ t)[n✝ + 1] = (hd :: tl)[n✝ + 1] t:Tmhd:Tmtl:List Tmih:∀ (l₁ l₂ : Nat), l₁ ≠ l₂ → (tl.set l₂ t)[l₁] = tl[l₁]n✝:Nat⊢ n✝ + 1 ≠ 0 → ((hd :: tl).set 0 t)[n✝ + 1] = (hd :: tl)[n✝ + 1]t:Tmhd:Tmtl:List Tmih:∀ (l₁ l₂ : Nat), l₁ ≠ l₂ → (tl.set l₂ t)[l₁] = tl[l₁]n✝¹:Natn✝:Nat⊢ n✝¹ + 1 ≠ n✝ + 1 → ((hd :: tl).set (n✝ + 1) t)[n✝¹ + 1] = (hd :: tl)[n✝¹ + 1] t:Tmhd:Tmtl:List Tmih:∀ (l₁ l₂ : Nat), l₁ ≠ l₂ → (tl.set l₂ t)[l₁] = tl[l₁]⊢ 0 ≠ 0 → ((hd :: tl).set 0 t)[0] = (hd :: tl)[0]t:Tmhd:Tmtl:List Tmih:∀ (l₁ l₂ : Nat), l₁ ≠ l₂ → (tl.set l₂ t)[l₁] = tl[l₁]n✝:Nat⊢ 0 ≠ n✝ + 1 → ((hd :: tl).set (n✝ + 1) t)[0] = (hd :: tl)[0]t:Tmhd:Tmtl:List Tmih:∀ (l₁ l₂ : Nat), l₁ ≠ l₂ → (tl.set l₂ t)[l₁] = tl[l₁]n✝:Nat⊢ n✝ + 1 ≠ 0 → ((hd :: tl).set 0 t)[n✝ + 1] = (hd :: tl)[n✝ + 1]t:Tmhd:Tmtl:List Tmih:∀ (l₁ l₂ : Nat), l₁ ≠ l₂ → (tl.set l₂ t)[l₁] = tl[l₁]n✝¹:Natn✝:Nat⊢ n✝¹ + 1 ≠ n✝ + 1 → ((hd :: tl).set (n✝ + 1) t)[n✝¹ + 1] = (hd :: tl)[n✝¹ + 1] All goals completed! 🐙
9.3.3. Reduction
Next, we need to extend the operational semantics to take
stores into account. Since the result of reducing an expression
will in general depend on the contents of the store in which it is
reduced, the evaluation rules should take not just a term but
also a store as argument. Furthermore, since the reduction of a
term can cause side effects on the store, and these may affect the
reduction of other terms in the future, the reduction rules need
to return a new store. Thus, the shape of the single-step
reduction relation needs to change from t ⟶ t' to t / ρ ⟶ t' / ρ',
where ρ and ρ' are the starting and ending states of
the store.
To carry through this change, we first need to augment all of our existing reduction rules with stores:
value v₂
---------------------------------- (appAbs)
(λx:τ₂,t₁) v₂ / ρ ⟶ [x:=v₂]t₁ / ρ
t₁ / ρ ⟶ t₁' / ρ'
-------------------------------- (app₁)
t₁ t₂ / ρ ⟶ t₁' t₂ / ρ'
value v₁
t₂ / ρ ⟶ t₂' / ρ'
-------------------------------- (app₂)
v₁ t₂ / ρ ⟶ v₁ t₂' / ρ'
Note that the first rule here returns the store unchanged, since function application, in itself, has no side effects. The other two rules simply propagate side effects from premise to conclusion.
Now, the result of reducing a ref expression will be a fresh
location; this is why we included locations in the syntax of terms
and in the set of values. It is crucial to note that making this
extension to the syntax of terms does not mean that we intend
programmers to write terms involving explicit, concrete locations:
such terms will arise only as intermediate results during reduction.
This may seem odd, but it follows naturally from our design decision
to represent the result of every reduction step by a modified term.
If we had chosen a more "machine-like" model, e.g., with an explicit
stack to contain values of bound identifiers, then the idea of adding
locations to the set of allowed values might seem more obvious.
In terms of this expanded syntax, we can state reduction rules
for the new constructs that manipulate locations and the store.
First, to reduce a dereferencing expression !t₁, we must first
reduce t₁ until it becomes a value:
t₁ / ρ ⟶ t₁' / ρ'
-------------------- (deref)
!t₁ / ρ ⟶ !t₁' / ρ'
Once t₁ has finished reducing, we should have an expression of
the form !l, where l is some location. (A term that attempts
to dereference any other sort of value, such as a function or
unit, is erroneous, as is a term that tries to dereference a
location that is larger than the size ρ.length of the currently
allocated store; the reduction rules simply get stuck in this
case. The type-safety properties established below assure us
that well-typed terms will never misbehave in this way.)
l < ρ.length
------------------------ (derefLoc)
!(loc l) / ρ ⟶ ρ[l] / ρ
Next, to reduce an assignment expression t₁:=t₂, we must first
reduce t₁ until it becomes a value (a location), and then
reduce t₂ until it becomes a value (of any sort):
t₁ / ρ ⟶ t₁' / ρ'
------------------------------ (assign₁)
t₁ := t₂ / ρ ⟶ t₁' := t₂ / ρ'
t₂ / ρ ⟶ t₂' / ρ'
------------------------------ (assign₂)
v₁ := t₂ / ρ ⟶ v₁ := t₂' / ρ'
Once we have finished with t₁ and t₂, we have an expression of
the form l:=v, which we execute by updating the store to make
location l contain v:
l < ρ.length
-------------------------------- (assign)
loc l := v / ρ ⟶ unit / [l:=v]ρ
The notation [l:=v]ρ means "the store that maps l to v
and maps all other locations to the same thing as ρ". Note
that the term resulting from this reduction step is just unit;
the interesting result is the updated store.
Finally, to reduce an expression of the form ref t₁, we first
reduce t₁ until it becomes a value:
t₁ / ρ ⟶ t₁' / ρ'
-------------------------- (ref)
ref t₁ / ρ ⟶ ref t₁' / ρ'
Then, to reduce the ref itself, we choose a fresh location at
the end of the current store — i.e., location ρ.length — and yield
a new store that extends ρ with the new value v.
-------------------------------- (refValue)
ref v / ρ ⟶ loc ρ.length / ρ, v
The value resulting from this step is the newly allocated location
itself. (Formally, ρ, v means ρ.concat v — i.e., to add
a new reference cell to the store, we append it to the end.)
Note that these reduction rules do not perform any kind of garbage collection: we simply allow the store to keep growing without bound as reduction proceeds. This does not affect the correctness of the results of reduction (after all, the definition of "garbage" is precisely parts of the store that are no longer reachable and so cannot play any further role in reduction), but it means that a naive implementation of our evaluator might run out of memory where a more sophisticated evaluator would be able to continue by reusing locations whose contents have become garbage.
Here are the rules again, formally:
section
set_option hygiene false in
local notation:40
t:71 " / " ρ:41 " ⟶ " t':71 " / " ρ':41 =>
Step (t, ρ) (t', ρ')
inductive Step : Tm × Store → Tm × Store → Prop where
-- pure STLC
| appAbs {x : String} {τ₂ : Ty} {t₁ v₂ : Tm} {ρ : Store}
(h : v₂.IsValue) :
<{(λ x : τ₂ . t₁) v₂}> / ρ ⟶
<{ [x := v₂] t₁ }> / ρ
| app₁ {t₁ t₁' t₂ : Tm} {ρ ρ' : Store}
(h : t₁ / ρ ⟶ t₁' / ρ') :
<{t₁ t₂}> / ρ ⟶ <{t₁' t₂}> / ρ'
| app₂ {v₁ t₂ t₂' : Tm} {ρ ρ' : Store}
(h₁ : v₁.IsValue)
(h₂ : t₂ / ρ ⟶ t₂' / ρ') :
<{v₁ t₂}> / ρ ⟶ <{v₁ t₂'}> / ρ'
-- numbers
| succNat {n : Nat} {ρ : Store} :
<{ succ ~(Tm.const n) }> / ρ ⟶ Tm.const (n + 1) / ρ
| succ {t₁ t₁' : Tm} {ρ ρ' : Store}
(h : t₁ / ρ ⟶ t₁' / ρ') :
<{ succ t₁ }> / ρ ⟶ <{ succ t₁' }> / ρ'
| predConst {n : Nat} {ρ : Store} :
<{ pred ~(Tm.const n) }> / ρ ⟶ Tm.const (n - 1) / ρ
| pred {t₁ t₁' : Tm} {ρ ρ' : Store}
(h : t₁ / ρ ⟶ t₁' / ρ') :
<{ pred t₁ }> / ρ ⟶ <{ pred t₁' }> / ρ'
| multConst {n₁ n₂ : Nat} {ρ : Store} :
<{ ~(Tm.const n₁) * ~(Tm.const n₂) }> / ρ ⟶
Tm.const (n₁ * n₂) / ρ
| mult₁ {t₁ t₁' t₂ : Tm} {ρ ρ' : Store}
(h : t₁ / ρ ⟶ t₁' / ρ') :
<{ t₁ * t₂ }> / ρ ⟶ <{ t₁' * t₂ }> / ρ'
| mult₂ {v₁ t₂ t₂' : Tm} {ρ ρ' : Store}
(h₁ : v₁.IsValue)
(h₂ : t₂ / ρ ⟶ t₂' / ρ') :
<{ v₁ * t₂ }> / ρ ⟶ <{ v₁ * t₂' }> / ρ'
| if0Step {t₁ t₁' t₂ t₃ : Tm} {ρ ρ' : Store}
(h : t₁ / ρ ⟶ t₁' / ρ') :
<{ if0 t₁ then t₂ else t₃ }> / ρ ⟶
<{ if0 t₁' then t₂ else t₃ }> / ρ'
| if0Zero {t₂ t₃ : Tm} {ρ : Store} :
<{ if0 0 then t₂ else t₃ }> / ρ ⟶ t₂ / ρ
| if0Nonzero {n : Nat} {t₂ t₃ : Tm} {ρ : Store} :
<{ if0 ~(Tm.const (n + 1)) then t₂ else t₃ }> / ρ ⟶
t₃ / ρ
-- references
| refValue {v : Tm} {ρ : Store}
(h : v.IsValue) :
<{ ref v }> / ρ ⟶ Tm.loc ρ.length / ρ.concat v
| ref_ {t₁ t₁' : Tm} {ρ ρ' : Store}
(h : t₁ / ρ ⟶ t₁' / ρ') :
<{ ref t₁ }> / ρ ⟶ <{ ref t₁' }> / ρ'
| derefLoc {l : Nat} {ρ : Store}
(h : l < ρ.length) :
<{ !~(Tm.loc l) }> / ρ ⟶ ρ[l] / ρ
| deref {t₁ t₁' : Tm} {ρ ρ' : Store}
(h : t₁ / ρ ⟶ t₁' / ρ') :
<{ !t₁ }> / ρ ⟶ <{ !t₁' }> / ρ'
| assign {v : Tm} {l : Nat} {ρ : Store}
(h₁ : v.IsValue)
(h₂ : l < ρ.length) :
<{ ~(Tm.loc l) := v }> / ρ ⟶ <{ unit }> / ρ.set l v
| assign₁ {t₁ t₁' t₂ : Tm} {ρ ρ' : Store}
(h : t₁ / ρ ⟶ t₁' / ρ') :
<{ t₁ := t₂ }> / ρ ⟶ <{ t₁' := t₂ }> / ρ'
| assign₂ {v₁ t₂ t₂' : Tm} {ρ ρ' : Store}
(h₁ : v₁.IsValue)
(h₂ : t₂ / ρ ⟶ t₂' / ρ') :
<{ v₁ := t₂ }> / ρ ⟶ <{ v₁ := t₂' }> / ρ'
end
scoped notation:40
t:71 " / " ρ:41 " ⟶ " t':71 " / " ρ':41 =>
Step (t, ρ) (t', ρ')
scoped notation:40
t:71 " / " ρ:41 " ⟶* " t':71 " / " ρ':41 =>
Multi Step (t, ρ) (t', ρ')
attribute [StlcRefEval] Step.appAbs Step.app₁ Step.app₂
Step.succ Step.succNat Step.pred Step.predConst
Step.multConst Step.mult₁ Step.mult₂
Step.if0Step Step.if0Zero Step.if0Nonzero
Step.refValue Step.ref_ Step.derefLoc Step.deref Step.assign
Step.assign₁ Step.assign₂
9.4. Typing
The contexts assigning types to free variables are exactly the same as for the STLC: partial maps from identifiers to types.
abbrev Context := PartialMap String Ty
9.4.1. Store typings
Having extended our syntax and reduction rules to accommodate references, our last job is to write down typing rules for the new constructs (and, of course, to check that these rules are sound!).
Naturally, the key question is, "What is the type of a location?"
First of all, notice that this question doesn't arise when typechecking terms that programmers actually write. Concrete location constants arise only in terms that are the intermediate results of reduction; they are not in the language that programmers write. So we only need to determine the type of a location when we're in the middle of a reduction sequence, e.g., trying to apply the progress or preservation lemmas. Thus, even though we normally think of typing as a static program property, it makes sense for the typing of locations to depend on the dynamic progress of the program too.
As a first try, note that when we reduce a term containing
concrete locations, the type of the result depends on the contents
of the store that we start with. For example, if we reduce the
term !(loc 1) in the store unit, unit, the result is unit;
if we reduce the same term in the store unit, λX:Unit.X, the
result is λX:Unit.X. With respect to the former store, the
location 1 has type Unit, and with respect to the latter it
has type Unit→Unit. This observation leads us immediately to a
first attempt at a typing rule for locations:
Γ ⊢ ρ[l] : τ₁
------------------
Γ ⊢ loc l : Ref τ₁
But where does ρ come from?
That is, to find the type of a location l, we look up the
current contents of l in the store and calculate the type τ₁
of the contents. The type of the location is then Ref τ₁.
Having begun in this way, we need to go a little further to reach a
consistent state. In effect, by making the type of a term depend on
the store, we have changed the typing relation from a three-place
relation (between contexts, terms, and types) to a four-place relation
(between contexts, stores, terms, and types). Since the store is,
intuitively, part of the context in which we calculate the type of a
term, let's write this four-place relation with the store to the left
of the turnstile: Γ; ρ ⊢ t : τ. Our rule for typing
references now has the form
Γ; ρ ⊢ ρ[l] : τ₁
---------------------
Γ; ρ ⊢ loc l : Ref τ₁
and all the rest of the typing rules in the system are extended similarly with stores. (The other rules do not need to do anything interesting with their stores — just pass them from premise to conclusion.)
However, this rule will not quite do. For one thing, typechecking
is rather inefficient, since calculating the type of a location l
involves calculating the type of the current contents v of l. If
l appears many times in a term τ, we will re-calculate the type of
v many times in the course of constructing a typing derivation for
τ. Worse, if v itself contains locations, then we will have to
recalculate their types each time they appear. Worse yet, the
proposed typing rule for locations may not allow us to derive
anything at all if the store contains a cycle. For example,
there is no finite typing derivation for the location 0 with respect
to this store:
λX:Nat. (!(loc 1)) X, λX:Nat. (!(loc 0)) X
Can you find a term whose reduction will create this particular cyclic store?
theorem cyclic_store:
∃ t,
t / [] ⟶*
<{ unit }> / (<{ λX:Nat. (!(loc 1)) X }> :: <{ λX:Nat. (!(loc 0)) X }> :: []) := ⊢ ∃ t, t / [] ⟶* <{ unit }> / [<{ λ X : Nat . (!(loc 1)) X }>, <{ λ X : Nat . (!(loc 0)) X }>]
solution!
-- `(λR:τ. t₂) t₁` acts as `let R : τ = t₁ in t₂`
⊢ <{
(λ R₀ : Ref (Nat → Nat) . (λ R₁ : Ref (Nat → Nat) . R₀ := (λ X : Nat . (!R₁) X)) (ref (λ X : Nat . (!R₀) X)))
(ref (λ X : Nat . X)) }> /
[] ⟶* <{ unit }> / [<{ λ X : Nat . (!(loc 1)) X }>, <{ λ X : Nat . (!(loc 0)) X }>]
repeat
⊢ Step
(<{ unit }>,
(([].concat (<{ λ X : Nat . X }>)).concat (<{ [R₀ := ~(Tm.loc [].length)] (λ X : Nat . (!R₀) X) }>)).set [].length
(<{
[R₁ := ~(Tm.loc ([].concat (<{ λ X : Nat . X }>)).length)]
[R₀ := ~(Tm.loc [].length)] (λ X : Nat . (!R₁) X) }>))
?h₂.h₂.h₂.h₂.h₂.y⊢ ?h₂.h₂.h₂.h₂.h₂.y ⟶* (<{ unit }>, [<{ λ X : Nat . (!(loc 1)) X }>, <{ λ X : Nat . (!(loc 0)) X }>])⊢ Tm × Store
⊢ ?h₂.h₂.h₂.h₂.h₂.y ⟶* (<{ unit }>, [<{ λ X : Nat . (!(loc 1)) X }>, <{ λ X : Nat . (!(loc 0)) X }>])⊢ Tm × Store
All goals completed! 🐙
These problems arise from the fact that our proposed typing rule for locations requires us to recalculate the type of a location every time we mention it in a term. But this, intuitively, should not be necessary. After all, when a location is first created, we know the type of the initial value that we are storing into it. Suppose we are willing to enforce the invariant that the type of the value contained in a given location never changes; that is, although we may later store other values into this location, those other values will always have the same type as the initial one. In other words, we always have in mind a single, definite type for every location in the store, which is fixed when the location is allocated. Then these intended types can be collected together as a store typing — a finite function mapping locations to types.
As with the other type systems we've seen, this conservative typing restriction on allowed updates means that we will rule out as ill-typed some programs that could reduce perfectly well without getting stuck.
Just as we did for stores, we will represent a store type simply
as a list of types: the type at index i records the type of the
values that we expect to be stored in cell i.
abbrev StoreTy := List Ty
open scoped MyGetElem
instance : MyGetElem StoreTy Nat Ty where
getElem δ n := δ.getD n <{Unit}>
@[simp]
theorem StoreTy_get_succ_tl (hd : Ty) (tl : StoreTy) (n : Nat) :
(hd :: tl)[n + 1] = tl[n] := hd:Tytl:StoreTyn:Nat⊢ (hd :: tl)[n + 1] = tl[n] All goals completed! 🐙
@[simp]
theorem StoreTy_get_zero_hd (hd : Ty) (tl : StoreTy) :
(hd :: tl)[0] = hd := hd:Tytl:StoreTy⊢ (hd :: tl)[0] = hd All goals completed! 🐙
Suppose we are given a store typing δ describing the store
ρ in which some term τ will be reduced. Then we can use
δ to calculate the type of the result of τ without ever
looking directly at ρ. For example, if δ is Unit, Unit→Unit,
then we can immediately infer that !(loc 1) has
type Unit→Unit. More generally, the typing rule for locations
can be reformulated in terms of store typings like this:
l < δ.length
-----------------------
Γ; δ ⊢ loc l : Ref δ[l]
That is, as long as l is a valid location, we can compute the
type of l just by looking it up in δ. Typing is again a
four-place relation, but it is parameterized on a store typing
rather than a concrete store. The rest of the typing rules are
analogously augmented with store typings.
9.4.2. The Typing Relation
We can now formalize the typing relation for the STLC with
references. Here, again, are the rules we're adding to the base
STLC (with numbers and Unit):
l < δ.length
----------------------- (loc)
Γ; δ ⊢ loc l : Ref δ[l]
Γ; δ ⊢ t₁ : τ₁
---------------------- (ref)
Γ; δ ⊢ ref t₁ : Ref τ₁
Γ; δ ⊢ t₁ : Ref τ₁
------------------ (deref)
Γ; δ ⊢ !t₁ : τ₁
Γ; δ ⊢ t₁ : Ref τ₂
Γ; δ ⊢ t₂ : τ₂
---------------------- (assign)
Γ; δ ⊢ t₁ := t₂ : Unit
inductive HasType (δ : StoreTy) : Context → Tm → Ty → Prop where
-- pure STLC
| var {Γ : Context} {x : String} {τ₁ : Ty}
(h : Γ[x] = some τ₁) :
<{ Γ / δ ⊢ ~(Tm.var x) ⦂ τ₁ }>
| abs {Γ : Context} {x : String} {τ₁ τ₂ : Ty} {t₁ : Tm}
(h : <{ x ↦ τ₂ ; Γ / δ ⊢ t₁ ⦂ τ₁ }>) :
<{ Γ / δ ⊢ λ x : τ₂ . t₁ ⦂ τ₂ → τ₁ }>
| app {Γ : Context} {τ₁ τ₂ : Ty} {t₁ t₂ : Tm}
(h₁ : <{ Γ / δ ⊢ t₁ ⦂ τ₂ → τ₁ }>)
(h₂ : <{ Γ / δ ⊢ t₂ ⦂ τ₂ }>) :
<{ Γ / δ ⊢ t₁ t₂ ⦂ τ₁ }>
-- numbers
| const {Γ : Context} {n : Nat} :
<{ Γ / δ ⊢ ~(Tm.const n) ⦂ Nat }>
| succ {Γ : Context} {t₁ : Tm}
(h : <{ Γ / δ ⊢ t₁ ⦂ Nat }>) :
<{ Γ / δ ⊢ succ t₁ ⦂ Nat }>
| pred {Γ : Context} {t₁ : Tm}
(h : <{ Γ / δ ⊢ t₁ ⦂ Nat }>) :
<{ Γ / δ ⊢ pred t₁ ⦂ Nat }>
| mult {Γ : Context} {t₁ t₂ : Tm}
(h₁ : <{ Γ / δ ⊢ t₁ ⦂ Nat }>)
(h₂ : <{ Γ / δ ⊢ t₂ ⦂ Nat }>) :
<{ Γ / δ ⊢ t₁ * t₂ ⦂ Nat }>
| ite0 {Γ : Context} {t₁ t₂ t₃ : Tm} {τ : Ty}
(h₁ : <{ Γ / δ ⊢ t₁ ⦂ Nat }>)
(h₂ : <{ Γ / δ ⊢ t₂ ⦂ τ }>)
(h₃ : <{ Γ / δ ⊢ t₃ ⦂ τ }>) :
<{ Γ / δ ⊢ if0 t₁ then t₂ else t₃ ⦂ τ }>
-- unit
| unit {Γ : Context} :
<{ Γ / δ ⊢ unit ⦂ Unit }>
-- references
| loc_ {Γ : Context} {l : Nat}
(h : l < δ.length) :
<{ Γ / δ ⊢ ~(Tm.loc l) ⦂ Ref ~(δ[l]) }>
| ref_ {Γ : Context} {t₁ : Tm} {τ₁ : Ty}
(h : <{ Γ / δ ⊢ t₁ ⦂ τ₁ }>) :
<{ Γ / δ ⊢ ref t₁ ⦂ Ref τ₁ }>
| deref {Γ : Context} {t₁ : Tm} {τ₁ : Ty}
(h : <{ Γ / δ ⊢ t₁ ⦂ Ref τ₁ }>) :
<{ Γ / δ ⊢ !t₁ ⦂ τ₁ }>
| assign {Γ : Context} {t₁ t₂ : Tm} {τ₂ : Ty}
(h₁ : <{ Γ / δ ⊢ t₁ ⦂ Ref τ₂ }>)
(h₂ : <{ Γ / δ ⊢ t₂ ⦂ τ₂ }>) :
<{ Γ / δ ⊢ t₁ := t₂ ⦂ Unit }>
attribute [StlcRefTyping] HasType.var HasType.abs HasType.app
HasType.const HasType.succ HasType.pred HasType.mult
HasType.ite0 HasType.unit
HasType.loc_ HasType.ref_ HasType.deref HasType.assign
Notation encoding
open Lean PrettyPrinter StlcCommon.Delab in
@[app_unexpander HasType]
def HasType.unexpand : Unexpander
| `($_ $δ $Γ $t $T) => do
let Γ' ← unexpandCtx Γ
`(<{ $Γ':stlcCtx / $δ ⊢ $(getTm t):stlcTm ⦂ $(getTy T):stlcTy }>)
| _ => throw ()
Of course, these typing rules will accurately predict the results
of reduction only if the concrete store used during reduction
actually conforms to the store typing that we assume for purposes
of typechecking. This proviso exactly parallels the situation
with free variables in the basic STLC: the substitution lemma
promises that, if Γ / δ ⊢ t : T, then we can replace the free
variables in τ with values of the types listed in Γ to
obtain a closed term of type τ, which, by the type preservation
theorem will reduce to a final result of type τ if it yields
any result at all. We will see below how to formalize an
analogous intuition for stores and store typings.
However, for purposes of typechecking the terms that programmers actually write, we do not need to do anything tricky to guess what store typing we should use. Concrete locations arise only in terms that are the intermediate results of reduction; they are not in the language that programmers write. Thus, we can simply typecheck the programmer's terms with respect to the empty store typing. As reduction proceeds and new locations are created, we will always be able to see how to extend the store typing by looking at the type of the initial values being placed in newly allocated cells; this intuition is formalized in the statement of the type preservation theorem below.
9.5. Properties
Our final task is to check that standard type safety properties continue to hold for the STLC with references. The progress theorem ("well-typed terms are not stuck") can be stated and proved almost as for the STLC; we just need to add a few straightforward cases to the proof to deal with the new constructs. The preservation theorem is a bit more interesting, so let's look at it first.
9.5.1. Well-Typed Stores
Since we have extended both the reduction relation (with initial and final stores) and the typing relation (with a store typing), we need to change the statement of preservation to include these parameters. But clearly we cannot just add stores and store typings without saying anything about how they are related — i.e., this is wrong:
theorem preservation_wrong (δ : StoreTy) (τ : Ty) (t t' : Tm) (ρ ρ' : Store) :
<{ ∅ / δ ⊢ t ⦂ τ }> →
t / ρ ⟶ t' / ρ' →
<{ ∅ / δ ⊢ t' ⦂ τ }> := by
If we typecheck with respect to some set of assumptions
about the types of the values in the store and then reduce with
respect to a store that violates these assumptions, the result
will be disaster. We say that a store ρ is well typed with
respect to a store typing δ if the term at each location l in
ρ has the type at location l in δ. Since only closed
terms ever get stored in locations (why?), it suffices to type
them in the empty context. The following definition of
StoreWellTyped formalizes this:
def StoreWellTyped (δ:StoreTy) (ρ:Store) :=
δ.length = ρ.length ∧
(∀ (l : Nat), l < ρ.length → <{ ∅ / δ ⊢ ~(ρ[l]) ⦂ ~(δ[l]) }>)
Informally, we will write δ ⊢ ρ for StoreWellTyped δ ρ.
scoped notation:40 δ:41 " ⊢ " ρ:41 => StoreWellTyped δ ρ
Intuitively, a store ρ is consistent with a store typing
δ if every value in the store has the type predicted by the
store typing. The only subtle point is the fact that, when typing
the values in the store, we supply the very same store typing to
the typing relation. This allows us to type circular stores like
the one we saw above.
Can you find a store ρ, and two
different store typings δ₁ and δ₂ such that both
δ₁ ⊢ ρ and δ₂ ⊢ ρ?
Let ρ be a store with a single location 0, such that
ρ = λX:Unit. (!(loc 0))(X).
Then ρ is well typed with
respect to both of the following store typings:
δ₁ = Unit → Unit
δ₂ = Unit → (Unit→Unit).
In fact, it is well typed with respect to any store typing of the form
δ = Unit → τ
for any type τ.
theorem store_not_unique:
exists ρ, exists δ₁, exists δ₂,
δ₁ ⊢ ρ ∧ δ₂ ⊢ ρ ∧ δ₁ ≠ δ₂ := ⊢ ∃ ρ δ₁ δ₂, δ₁ ⊢ ρ ∧ δ₂ ⊢ ρ ∧ δ₁ ≠ δ₂
solution!
⊢ ∃ δ₁ δ₂, δ₁ ⊢ [<{ λ X : Unit . (!(loc 0)) X }>] ∧ δ₂ ⊢ [<{ λ X : Unit . (!(loc 0)) X }>] ∧ δ₁ ≠ δ₂;
⊢ ∃ δ₂,
[<{ Unit → Unit }>] ⊢ [<{ λ X : Unit . (!(loc 0)) X }>] ∧
δ₂ ⊢ [<{ λ X : Unit . (!(loc 0)) X }>] ∧ [<{ Unit → Unit }>] ≠ δ₂;
⊢ [<{ Unit → Unit }>] ⊢ [<{ λ X : Unit . (!(loc 0)) X }>] ∧
[<{ Unit → Nat }>] ⊢ [<{ λ X : Unit . (!(loc 0)) X }>] ∧ [<{ Unit → Unit }>] ≠ [<{ Unit → Nat }>];
⊢ [<{ Unit → Unit }>] ⊢ [<{ λ X : Unit . (!(loc 0)) X }>]⊢ [<{ Unit → Nat }>] ⊢ [<{ λ X : Unit . (!(loc 0)) X }>] ∧ [<{ Unit → Unit }>] ≠ [<{ Unit → Nat }>]
⊢ [<{ Unit → Unit }>] ⊢ [<{ λ X : Unit . (!(loc 0)) X }>] ⊢ <{ ∅ / [<{ Unit → Unit }>] ⊢ λ X : Unit . (!(loc 0)) X ⦂ Unit → Unit }>
⊢ 0 < [<{ Unit → Unit }>].length
All goals completed! 🐙
⊢ [<{ Unit → Nat }>] ⊢ [<{ λ X : Unit . (!(loc 0)) X }>] ∧ [<{ Unit → Unit }>] ≠ [<{ Unit → Nat }>] ⊢ [<{ Unit → Nat }>] ⊢ [<{ λ X : Unit . (!(loc 0)) X }>]⊢ [<{ Unit → Unit }>] ≠ [<{ Unit → Nat }>]
⊢ [<{ Unit → Nat }>] ⊢ [<{ λ X : Unit . (!(loc 0)) X }>] ⊢ <{ ∅ / [<{ Unit → Nat }>] ⊢ λ X : Unit . (!(loc 0)) X ⦂ Unit → Nat }>
⊢ 0 < [<{ Unit → Nat }>].length
All goals completed! 🐙
⊢ [<{ Unit → Unit }>] ≠ [<{ Unit → Nat }>] All goals completed! 🐙
We can now state something closer to the desired preservation property:
theorem preservation_less_wrong (δ : StoreTy) (τ : Ty) (t t' : Tm) (ρ ρ' : Store) :
<{ ∅ / δ ⊢ t ⦂ τ }> →
t / ρ ⟶ t' / ρ' →
δ ⊢ ρ →
<{ ∅ / δ ⊢ t' ⦂ τ }> := by
This statement is fine for all of the reduction rules except
the allocation rule refValue. The problem is that this rule
yields a store with a larger domain than the initial store, which
falsifies the conclusion of the above statement: if ρ' includes
a binding for a fresh location l, then l cannot be in the
domain of δ, and it will not be the case that t' (which
definitely mentions l) is typable under δ.
9.5.2. Extending Store Typings
Evidently, since the store can increase in size during
reduction, we need to allow the store typing to grow during
reduction as well. This motivates the following definition. We
say that the store type δ' extends δ if δ' is just δ
with some new types added to the end.
inductive Extends : StoreTy → StoreTy → Prop where
| nil (δ' : StoreTy) : Extends δ' []
| cons (τ : Ty) {δ' δ : StoreTy} (h : Extends δ' δ) :
Extends (τ::δ') (τ::δ)
attribute [StlcRefTyping] Extends.nil Extends.cons
For example, the store typing [Nat] with a single location of
type Nat extends the empty store typing.
We'll need a few technical lemmas about extended contexts. First, looking up a type in an extended store typing yields the same result as in the original:
theorem extends_lookup {l : Nat} {δ δ' : StoreTy}
(h₁ : l < δ.length)
(h₂ : Extends δ' δ) :
δ'[l] = δ[l] := l:Natδ:StoreTyδ':StoreTyh₁:l < List.length δh₂:Extends δ' δ⊢ δ'[l] = δ[l]
induction δ generalizing l δ' with
l:Natδ':StoreTyh₁:l < [].lengthh₂:Extends δ' []⊢ δ'[l] = [][l] All goals completed! 🐙
hd:Tytl:List Tyih:∀ {l : Nat} {δ' : StoreTy}, l < tl.length → Extends δ' tl → δ'[l] = tl[l]l:Natδ':StoreTyh₁:l < (hd :: tl).lengthh₂:Extends δ' (hd :: tl)⊢ δ'[l] = (hd :: tl)[l]
cases δ' with
hd:Tytl:List Tyih:∀ {l : Nat} {δ' : StoreTy}, l < tl.length → Extends δ' tl → δ'[l] = tl[l]l:Nath₁:l < (hd :: tl).lengthh₂:Extends [] (hd :: tl)⊢ [][l] = (hd :: tl)[l] All goals completed! 🐙
hd:Tytl:List Tyih:∀ {l : Nat} {δ' : StoreTy}, l < tl.length → Extends δ' tl → δ'[l] = tl[l]l:Nath₁:l < (hd :: tl).lengthhd':Tytl':List Tyh₂:Extends (hd' :: tl') (hd :: tl)⊢ (hd' :: tl')[l] = (hd :: tl)[l]
hd:Tytl:List Tyih:∀ {l : Nat} {δ' : StoreTy}, l < tl.length → Extends δ' tl → δ'[l] = tl[l]l:Nath₁:l < (hd :: tl).lengthtl':List Tyh✝:Extends tl' tl⊢ (hd :: tl')[l] = (hd :: tl)[l]
cases l with
hd:Tytl:List Tyih:∀ {l : Nat} {δ' : StoreTy}, l < tl.length → Extends δ' tl → δ'[l] = tl[l]tl':List Tyh✝:Extends tl' tlh₁:0 < (hd :: tl).length⊢ (hd :: tl')[0] = (hd :: tl)[0] All goals completed! 🐙
hd:Tytl:List Tyih:∀ {l : Nat} {δ' : StoreTy}, l < tl.length → Extends δ' tl → δ'[l] = tl[l]tl':List Tyh✝:Extends tl' tll:Nath₁:l + 1 < (hd :: tl).length⊢ (hd :: tl')[l + 1] = (hd :: tl)[l + 1]
hd:Tytl:List Tyih:∀ {l : Nat} {δ' : StoreTy}, l < tl.length → Extends δ' tl → δ'[l] = tl[l]tl':List Tyh✝:Extends tl' tll:Nath₁:l + 1 < (hd :: tl).length⊢ tl'[l] = tl[l]; hd:Tytl:List Tyih:∀ {l : Nat} {δ' : StoreTy}, l < tl.length → Extends δ' tl → δ'[l] = tl[l]tl':List Tyh✝:Extends tl' tll:Nath₁:l + 1 < (hd :: tl).length⊢ l < tl.lengthhd:Tytl:List Tyih:∀ {l : Nat} {δ' : StoreTy}, l < tl.length → Extends δ' tl → δ'[l] = tl[l]tl':List Tyh✝:Extends tl' tll:Nath₁:l + 1 < (hd :: tl).length⊢ Extends tl' tl
hd:Tytl:List Tyih:∀ {l : Nat} {δ' : StoreTy}, l < tl.length → Extends δ' tl → δ'[l] = tl[l]tl':List Tyh✝:Extends tl' tll:Nath₁:l + 1 < (hd :: tl).length⊢ l < tl.length All goals completed! 🐙
hd:Tytl:List Tyih:∀ {l : Nat} {δ' : StoreTy}, l < tl.length → Extends δ' tl → δ'[l] = tl[l]tl':List Tyh✝:Extends tl' tll:Nath₁:l + 1 < (hd :: tl).length⊢ Extends tl' tl All goals completed! 🐙
Next, if δ' extends δ, the length of δ' is at least that of δ.
theorem length_extends {l : Nat} {δ δ' : StoreTy}
(h₁ : l < δ.length)
(h₂ : Extends δ' δ) :
l < δ'.length := l:Natδ:StoreTyδ':StoreTyh₁:l < List.length δh₂:Extends δ' δ⊢ l < List.length δ'
induction h₂ generalizing l with
δ:StoreTyδ':StoreTyδ'✝:StoreTyl:Nath₁:l < [].length⊢ l < List.length δ'✝ All goals completed! 🐙
δ:StoreTyδ':StoreTyτ:Tyδ'✝:StoreTyδ✝:StoreTyh:Extends δ'✝ δ✝ih:∀ {l : Nat}, l < List.length δ✝ → l < List.length δ'✝l:Nath₁:l < (τ :: δ✝).length⊢ l < (τ :: δ'✝).length
δ:StoreTyδ':StoreTyτ:Tyδ'✝:StoreTyδ✝:StoreTyh:Extends δ'✝ δ✝ih:∀ {l : Nat}, l < List.length δ✝ → l < List.length δ'✝l:Nath₁:l < (τ :: δ✝).length⊢ l < List.length δ'✝ + 1
cases l with
δ:StoreTyδ':StoreTyτ:Tyδ'✝:StoreTyδ✝:StoreTyh:Extends δ'✝ δ✝ih:∀ {l : Nat}, l < List.length δ✝ → l < List.length δ'✝h₁:0 < (τ :: δ✝).length⊢ 0 < List.length δ'✝ + 1 All goals completed! 🐙
δ:StoreTyδ':StoreTyτ:Tyδ'✝:StoreTyδ✝:StoreTyh:Extends δ'✝ δ✝ih:∀ {l : Nat}, l < List.length δ✝ → l < List.length δ'✝l':Nath₁:l' + 1 < (τ :: δ✝).length⊢ l' + 1 < List.length δ'✝ + 1
δ:StoreTyδ':StoreTyτ:Tyδ'✝:StoreTyδ✝:StoreTyh:Extends δ'✝ δ✝ih:∀ {l : Nat}, l < List.length δ✝ → l < List.length δ'✝l':Nath₁:l' + 1 < (τ :: δ✝).length⊢ l' < List.length δ'✝; δ:StoreTyδ':StoreTyτ:Tyδ'✝:StoreTyδ✝:StoreTyh:Extends δ'✝ δ✝ih:∀ {l : Nat}, l < List.length δ✝ → l < List.length δ'✝l':Nath₁:l' + 1 < (τ :: δ✝).length⊢ l' < List.length δ✝
All goals completed! 🐙
Finally, δ ++ δ' extends δ, and Extends is reflexive.
theorem extends_app (δ δ' : StoreTy) : Extends (δ ++ δ') δ := δ:StoreTyδ':StoreTy⊢ Extends (δ ++ δ') δ
δ':StoreTy⊢ Extends ([] ++ δ') []head✝:Tytail✝:List Tytail_ih✝:∀ (δ' : StoreTy), Extends (tail✝ ++ δ') tail✝δ':StoreTy⊢ Extends (head✝ :: tail✝ ++ δ') (head✝ :: tail✝) δ':StoreTy⊢ Extends ([] ++ δ') []head✝:Tytail✝:List Tytail_ih✝:∀ (δ' : StoreTy), Extends (tail✝ ++ δ') tail✝δ':StoreTy⊢ Extends (head✝ :: tail✝ ++ δ') (head✝ :: tail✝) All goals completed! 🐙
theorem extends_refl (δ : StoreTy) : Extends δ δ := δ:StoreTy⊢ Extends δ δ
⊢ Extends [] []head✝:Tytail✝:List Tytail_ih✝:Extends tail✝ tail✝⊢ Extends (head✝ :: tail✝) (head✝ :: tail✝) ⊢ Extends [] []head✝:Tytail✝:List Tytail_ih✝:Extends tail✝ tail✝⊢ Extends (head✝ :: tail✝) (head✝ :: tail✝) All goals completed! 🐙
9.5.3. Preservation, Finally
We can now give the final, correct statement of the type preservation property:
def preservation_theorem {δ : StoreTy} {t t' : Tm} {τ : Ty} {ρ ρ' : Store} :=
(hTy : <{ ∅ / δ ⊢ t ⦂ τ }>) →
(hStoreTy : δ ⊢ ρ) →
(hEval : t / ρ ⟶ t' / ρ') →
∃ δ', Extends δ' δ ∧ (<{ ∅ / δ' ⊢ t' ⦂ τ }>) ∧ (δ' ⊢ ρ')
Note that the preservation theorem merely asserts that there
is some store typing δ' extending δ (i.e., agreeing with
δ on the values of all the old locations) such that the new
term t' is well typed with respect to δ'; it does not tell us
exactly what δ' is. It is intuitively clear, of course, that
δ' is either δ or else exactly δ ++ [τ₁], where τ₁
is the type of the value v₁ in the extended store ρ ++ [v₁],
but stating this explicitly would complicate the
statement of the theorem without making it any more useful: the
weaker version above is already in the right form (because its
conclusion implies its hypothesis) to "turn the crank" repeatedly
and conclude that every sequence of reduction steps preserves
well-typedness. Combining this with the progress property, we
obtain the usual guarantee that "well-typed programs never go
wrong."
In order to prove this, we'll need a few lemmas, as usual.
9.5.3.1. Substitution Lemma
First, we need an easy extension of the standard substitution lemma, along with the same machinery about context invariance that we used in the proof of the substitution lemma for the STLC.
theorem weakening {Γ Γ' : Context} {δ : StoreTy} {t : Tm} {τ: Ty}
(hi : Γ ⊆ Γ')
(ht : <{ Γ / δ ⊢ t ⦂ τ }>) :
<{ Γ' / δ ⊢ t ⦂ τ }> := Γ:ContextΓ':Contextδ:StoreTyt:Tmτ:Tyhi:Γ ⊆ Γ'ht:<{ Γ / δ ⊢ t ⦂ τ }>⊢ <{ Γ' / δ ⊢ t ⦂ τ }>
induction ht generalizing Γ' with (All goals completed! 🐙)
theorem weakening_empty {Γ : Context} {δ : StoreTy} {t : Tm} {τ: Ty}
(ht :<{ ∅ / δ ⊢ t ⦂ τ }>) :
<{ Γ / δ ⊢ t ⦂ τ }> := Γ:Contextδ:StoreTyt:Tmτ:Tyht:<{ ∅ / δ ⊢ t ⦂ τ }>⊢ <{ Γ / δ ⊢ t ⦂ τ }>
Γ:Contextδ:StoreTyt:Tmτ:Tyht:<{ ∅ / δ ⊢ t ⦂ τ }>⊢ ∅ ⊆ Γ
Γ:Contextδ:StoreTyt:Tmτ:Tyht:<{ ∅ / δ ⊢ t ⦂ τ }>a✝:Stringb✝:Tyh:∅[a✝] = some b✝⊢ Γ[a✝] = some b✝
Γ:Contextδ:StoreTyt:Tmτ:Tyht:<{ ∅ / δ ⊢ t ⦂ τ }>a✝:Stringb✝:Tyh:none = some b✝⊢ Γ[a✝] = some b✝
contradiction All goals completed! 🐙
theorem substitution_preserves_typing (Γ : Context) (δ : StoreTy) (x : String)
(τ₁ : Ty) (t v : Tm) (τ : Ty)
(ht : <{ x ↦ τ₁ ; Γ / δ⊢ t ⦂ τ }>)
(hv : <{ ∅ / δ ⊢ v ⦂ τ₁ }>) :
<{ Γ / δ ⊢ [x := v] t ⦂ τ }> := by Γ:Contextδ:StoreTyx:Stringτ₁:Tyt:Tmv:Tmτ:Tyht:<{ ~(x →ₚ τ₁ ; Γ) / δ ⊢ t ⦂ τ }>hv:<{ ∅ / δ ⊢ v ⦂ τ₁ }>⊢ <{ Γ / δ ⊢ [~x := v] t ⦂ τ }>
induction t generalizing Γ τ with (
rw [subst var δ:StoreTyx:Stringτ₁:Tyv:Tmhv:<{ ∅ / δ ⊢ v ⦂ τ₁ }>y:StringΓ:Contextτ:Tyht:<{ ~(x →ₚ τ₁ ; Γ) / δ ⊢ ~(STLCRef.Tm.var y) ⦂ τ }>⊢ <{ Γ / δ ⊢ ~(if x = y then v else STLCRef.Tm.var y) ⦂ τ }>] assign δ:StoreTyx:Stringτ₁:Tyv:Tmhv:<{ ∅ / δ ⊢ v ⦂ τ₁ }>a✝¹:Tma✝:Tma_ih✝¹:∀ (Γ : Context) (τ : Ty), <{ ~(x →ₚ τ₁ ; Γ) / δ ⊢ a✝¹ ⦂ τ }> → <{ Γ / δ ⊢ [~x := v] a✝¹ ⦂ τ }>a_ih✝:∀ (Γ : Context) (τ : Ty), <{ ~(x →ₚ τ₁ ; Γ) / δ ⊢ a✝ ⦂ τ }> → <{ Γ / δ ⊢ [~x := v] a✝ ⦂ τ }>Γ:Contextτ:Tyht:<{ ~(x →ₚ τ₁ ; Γ) / δ ⊢ a✝¹ := a✝ ⦂ τ }>⊢ <{ Γ / δ ⊢ [~x := v] a✝¹ := [~x := v] a✝ ⦂ τ }> loc δ:StoreTyx:Stringτ₁:Tyv:Tmhv:<{ ∅ / δ ⊢ v ⦂ τ₁ }>a✝:NatΓ:Contextτ:Tyht:<{ ~(x →ₚ τ₁ ; Γ) / δ ⊢ ~(Tm.loc a✝) ⦂ τ }>⊢ <{ Γ / δ ⊢ ~(Tm.loc a✝) ⦂ τ }>; try (inversion ht loc_ δ:StoreTyx:Stringτ₁:Tyv:Tmhv:<{ ∅ / δ ⊢ v ⦂ τ₁ }>a✝:NatΓ:Contexth✝:a✝ < List.length δ⊢ <{ Γ / δ ⊢ ~(Tm.loc a✝) ⦂ Ref ~δ[a✝] }>; apply_rules using StlcRefTyping All goals completed! 🐙; done))
| var y => var δ:StoreTyx:Stringτ₁:Tyv:Tmhv:<{ ∅ / δ ⊢ v ⦂ τ₁ }>y:StringΓ:Contextτ:Tyht:<{ ~(x →ₚ τ₁ ; Γ) / δ ⊢ ~(STLCRef.Tm.var y) ⦂ τ }>⊢ <{ Γ / δ ⊢ ~(if x = y then v else STLCRef.Tm.var y) ⦂ τ }>
inversion ht with | _ h => var δ:StoreTyx:Stringτ₁:Tyv:Tmhv:<{ ∅ / δ ⊢ v ⦂ τ₁ }>y:StringΓ:Contextτ:Tyh:(x →ₚ τ₁ ; Γ)[y] = some τ⊢ <{ Γ / δ ⊢ ~(if x = y then v else STLCRef.Tm.var y) ⦂ τ }>
by_cases h₁ : x = y pos δ:StoreTyx:Stringτ₁:Tyv:Tmhv:<{ ∅ / δ ⊢ v ⦂ τ₁ }>y:StringΓ:Contextτ:Tyh:(x →ₚ τ₁ ; Γ)[y] = some τh₁:x = y⊢ <{ Γ / δ ⊢ ~(if x = y then v else STLCRef.Tm.var y) ⦂ τ }>neg δ:StoreTyx:Stringτ₁:Tyv:Tmhv:<{ ∅ / δ ⊢ v ⦂ τ₁ }>y:StringΓ:Contextτ:Tyh:(x →ₚ τ₁ ; Γ)[y] = some τh₁:¬x = y⊢ <{ Γ / δ ⊢ ~(if x = y then v else STLCRef.Tm.var y) ⦂ τ }>
· pos δ:StoreTyx:Stringτ₁:Tyv:Tmhv:<{ ∅ / δ ⊢ v ⦂ τ₁ }>y:StringΓ:Contextτ:Tyh:(x →ₚ τ₁ ; Γ)[y] = some τh₁:x = y⊢ <{ Γ / δ ⊢ ~(if x = y then v else STLCRef.Tm.var y) ⦂ τ }> subst h₁ pos δ:StoreTyx:Stringτ₁:Tyv:Tmhv:<{ ∅ / δ ⊢ v ⦂ τ₁ }>Γ:Contextτ:Tyh:(x →ₚ τ₁ ; Γ)[x] = some τ⊢ <{ Γ / δ ⊢ ~(if x = x then v else STLCRef.Tm.var x) ⦂ τ }>; simp at h pos δ:StoreTyx:Stringτ₁:Tyv:Tmhv:<{ ∅ / δ ⊢ v ⦂ τ₁ }>Γ:Contextτ:Tyh:τ₁ = τ⊢ <{ Γ / δ ⊢ ~(if x = x then v else STLCRef.Tm.var x) ⦂ τ }>; subst h pos δ:StoreTyx:Stringτ₁:Tyv:Tmhv:<{ ∅ / δ ⊢ v ⦂ τ₁ }>Γ:Context⊢ <{ Γ / δ ⊢ ~(if x = x then v else STLCRef.Tm.var x) ⦂ τ₁ }>;
apply weakening_empty at hv pos δ:StoreTyx:Stringτ₁:Tyv:Tmhv✝:<{ ∅ / δ ⊢ v ⦂ τ₁ }>Γ:Contexthv:<{ ~?Γ / δ ⊢ v ⦂ τ₁ }>⊢ <{ Γ / δ ⊢ ~(if x = x then v else STLCRef.Tm.var x) ⦂ τ₁ }>Γ δ:StoreTyx:Stringτ₁:Tyv:Tmhv:<{ ∅ / δ ⊢ v ⦂ τ₁ }>Γ:Context⊢ Context
simp pos δ:StoreTyx:Stringτ₁:Tyv:Tmhv✝:<{ ∅ / δ ⊢ v ⦂ τ₁ }>Γ:Contexthv:<{ ~?Γ / δ ⊢ v ⦂ τ₁ }>⊢ <{ Γ / δ ⊢ v ⦂ τ₁ }>Γ δ:StoreTyx:Stringτ₁:Tyv:Tmhv:<{ ∅ / δ ⊢ v ⦂ τ₁ }>Γ:Context⊢ Context; assumption All goals completed! 🐙
· neg δ:StoreTyx:Stringτ₁:Tyv:Tmhv:<{ ∅ / δ ⊢ v ⦂ τ₁ }>y:StringΓ:Contextτ:Tyh:(x →ₚ τ₁ ; Γ)[y] = some τh₁:¬x = y⊢ <{ Γ / δ ⊢ ~(if x = y then v else STLCRef.Tm.var y) ⦂ τ }> rw [PartialMap.update_neq neg δ:StoreTyx:Stringτ₁:Tyv:Tmhv:<{ ∅ / δ ⊢ v ⦂ τ₁ }>y:StringΓ:Contextτ:Tyh:Γ[y] = some τh₁:¬x = y⊢ <{ Γ / δ ⊢ ~(if x = y then v else STLCRef.Tm.var y) ⦂ τ }>neg.h δ:StoreTyx:Stringτ₁:Tyv:Tmhv:<{ ∅ / δ ⊢ v ⦂ τ₁ }>y:StringΓ:Contextτ:Tyh:(x →ₚ τ₁ ; Γ)[y] = some τh₁:¬x = y⊢ x ≠ y] at h neg δ:StoreTyx:Stringτ₁:Tyv:Tmhv:<{ ∅ / δ ⊢ v ⦂ τ₁ }>y:StringΓ:Contextτ:Tyh:Γ[y] = some τh₁:¬x = y⊢ <{ Γ / δ ⊢ ~(if x = y then v else STLCRef.Tm.var y) ⦂ τ }>neg.h δ:StoreTyx:Stringτ₁:Tyv:Tmhv:<{ ∅ / δ ⊢ v ⦂ τ₁ }>y:StringΓ:Contextτ:Tyh:(x →ₚ τ₁ ; Γ)[y] = some τh₁:¬x = y⊢ x ≠ y <;> neg δ:StoreTyx:Stringτ₁:Tyv:Tmhv:<{ ∅ / δ ⊢ v ⦂ τ₁ }>y:StringΓ:Contextτ:Tyh:Γ[y] = some τh₁:¬x = y⊢ <{ Γ / δ ⊢ ~(if x = y then v else STLCRef.Tm.var y) ⦂ τ }>neg.h δ:StoreTyx:Stringτ₁:Tyv:Tmhv:<{ ∅ / δ ⊢ v ⦂ τ₁ }>y:StringΓ:Contextτ:Tyh:(x →ₚ τ₁ ; Γ)[y] = some τh₁:¬x = y⊢ x ≠ y simp_all All goals completed! 🐙
apply_rules using StlcRefTyping All goals completed! 🐙
| abs y _ _ ih => abs δ:StoreTyx:Stringτ₁:Tyv:Tmhv:<{ ∅ / δ ⊢ v ⦂ τ₁ }>y:Stringa✝¹:Tya✝:Tmih:∀ (Γ : Context) (τ : Ty), <{ ~(x →ₚ τ₁ ; Γ) / δ ⊢ a✝ ⦂ τ }> → <{ Γ / δ ⊢ [~x := v] a✝ ⦂ τ }>Γ:Contextτ:Tyht:<{ ~(x →ₚ τ₁ ; Γ) / δ ⊢ λ ~y : a✝¹ . a✝ ⦂ τ }>⊢ <{ Γ / δ ⊢ ~(if x = y then <{ λ ~y : a✝¹ . a✝ }> else <{ λ ~y : a✝¹ . [~x := v] a✝ }>) ⦂ τ }>
inversion ht with | _ h => abs δ:StoreTyx:Stringτ₁:Tyv:Tmhv:<{ ∅ / δ ⊢ v ⦂ τ₁ }>y:Stringa✝¹:Tya✝:Tmih:∀ (Γ : Context) (τ : Ty), <{ ~(x →ₚ τ₁ ; Γ) / δ ⊢ a✝ ⦂ τ }> → <{ Γ / δ ⊢ [~x := v] a✝ ⦂ τ }>Γ:Contextτ₁✝:Tyh:<{ ~(y →ₚ a✝¹ ; x →ₚ τ₁ ; Γ) / δ ⊢ a✝ ⦂ τ₁✝ }>⊢ <{ Γ / δ ⊢ ~(if x = y then <{ λ ~y : a✝¹ . a✝ }> else <{ λ ~y : a✝¹ . [~x := v] a✝ }>) ⦂ a✝¹ → τ₁✝ }>
by_cases h₁ : x = y pos δ:StoreTyx:Stringτ₁:Tyv:Tmhv:<{ ∅ / δ ⊢ v ⦂ τ₁ }>y:Stringa✝¹:Tya✝:Tmih:∀ (Γ : Context) (τ : Ty), <{ ~(x →ₚ τ₁ ; Γ) / δ ⊢ a✝ ⦂ τ }> → <{ Γ / δ ⊢ [~x := v] a✝ ⦂ τ }>Γ:Contextτ₁✝:Tyh:<{ ~(y →ₚ a✝¹ ; x →ₚ τ₁ ; Γ) / δ ⊢ a✝ ⦂ τ₁✝ }>h₁:x = y⊢ <{ Γ / δ ⊢ ~(if x = y then <{ λ ~y : a✝¹ . a✝ }> else <{ λ ~y : a✝¹ . [~x := v] a✝ }>) ⦂ a✝¹ → τ₁✝ }>neg δ:StoreTyx:Stringτ₁:Tyv:Tmhv:<{ ∅ / δ ⊢ v ⦂ τ₁ }>y:Stringa✝¹:Tya✝:Tmih:∀ (Γ : Context) (τ : Ty), <{ ~(x →ₚ τ₁ ; Γ) / δ ⊢ a✝ ⦂ τ }> → <{ Γ / δ ⊢ [~x := v] a✝ ⦂ τ }>Γ:Contextτ₁✝:Tyh:<{ ~(y →ₚ a✝¹ ; x →ₚ τ₁ ; Γ) / δ ⊢ a✝ ⦂ τ₁✝ }>h₁:¬x = y⊢ <{ Γ / δ ⊢ ~(if x = y then <{ λ ~y : a✝¹ . a✝ }> else <{ λ ~y : a✝¹ . [~x := v] a✝ }>) ⦂ a✝¹ → τ₁✝ }>
· pos δ:StoreTyx:Stringτ₁:Tyv:Tmhv:<{ ∅ / δ ⊢ v ⦂ τ₁ }>y:Stringa✝¹:Tya✝:Tmih:∀ (Γ : Context) (τ : Ty), <{ ~(x →ₚ τ₁ ; Γ) / δ ⊢ a✝ ⦂ τ }> → <{ Γ / δ ⊢ [~x := v] a✝ ⦂ τ }>Γ:Contextτ₁✝:Tyh:<{ ~(y →ₚ a✝¹ ; x →ₚ τ₁ ; Γ) / δ ⊢ a✝ ⦂ τ₁✝ }>h₁:x = y⊢ <{ Γ / δ ⊢ ~(if x = y then <{ λ ~y : a✝¹ . a✝ }> else <{ λ ~y : a✝¹ . [~x := v] a✝ }>) ⦂ a✝¹ → τ₁✝ }> simp_all [PartialMap.update_shadow] pos δ:StoreTyx:Stringτ₁:Tyv:Tmhv:<{ ∅ / δ ⊢ v ⦂ τ₁ }>y:Stringa✝¹:Tya✝:TmΓ:Contextτ₁✝:Tyih:∀ (Γ : Context) (τ : Ty), <{ ~(y →ₚ τ₁ ; Γ) / δ ⊢ a✝ ⦂ τ }> → <{ Γ / δ ⊢ [~y := v] a✝ ⦂ τ }>h:<{ ~(y →ₚ a✝¹ ; Γ) / δ ⊢ a✝ ⦂ τ₁✝ }>h₁:x = y⊢ <{ Γ / δ ⊢ λ ~y : a✝¹ . a✝ ⦂ a✝¹ → τ₁✝ }>; apply_rules using StlcRefTyping All goals completed! 🐙
· neg δ:StoreTyx:Stringτ₁:Tyv:Tmhv:<{ ∅ / δ ⊢ v ⦂ τ₁ }>y:Stringa✝¹:Tya✝:Tmih:∀ (Γ : Context) (τ : Ty), <{ ~(x →ₚ τ₁ ; Γ) / δ ⊢ a✝ ⦂ τ }> → <{ Γ / δ ⊢ [~x := v] a✝ ⦂ τ }>Γ:Contextτ₁✝:Tyh:<{ ~(y →ₚ a✝¹ ; x →ₚ τ₁ ; Γ) / δ ⊢ a✝ ⦂ τ₁✝ }>h₁:¬x = y⊢ <{ Γ / δ ⊢ ~(if x = y then <{ λ ~y : a✝¹ . a✝ }> else <{ λ ~y : a✝¹ . [~x := v] a✝ }>) ⦂ a✝¹ → τ₁✝ }> rw [PartialMap.update_permute neg δ:StoreTyx:Stringτ₁:Tyv:Tmhv:<{ ∅ / δ ⊢ v ⦂ τ₁ }>y:Stringa✝¹:Tya✝:Tmih:∀ (Γ : Context) (τ : Ty), <{ ~(x →ₚ τ₁ ; Γ) / δ ⊢ a✝ ⦂ τ }> → <{ Γ / δ ⊢ [~x := v] a✝ ⦂ τ }>Γ:Contextτ₁✝:Tyh:<{ ~(x →ₚ τ₁ ; y →ₚ a✝¹ ; Γ) / δ ⊢ a✝ ⦂ τ₁✝ }>h₁:¬x = y⊢ <{ Γ / δ ⊢ ~(if x = y then <{ λ ~y : a✝¹ . a✝ }> else <{ λ ~y : a✝¹ . [~x := v] a✝ }>) ⦂ a✝¹ → τ₁✝ }>neg δ:StoreTyx:Stringτ₁:Tyv:Tmhv:<{ ∅ / δ ⊢ v ⦂ τ₁ }>y:Stringa✝¹:Tya✝:Tmih:∀ (Γ : Context) (τ : Ty), <{ ~(x →ₚ τ₁ ; Γ) / δ ⊢ a✝ ⦂ τ }> → <{ Γ / δ ⊢ [~x := v] a✝ ⦂ τ }>Γ:Contextτ₁✝:Tyh:<{ ~(y →ₚ a✝¹ ; x →ₚ τ₁ ; Γ) / δ ⊢ a✝ ⦂ τ₁✝ }>h₁:¬x = y⊢ y ≠ x] at h neg δ:StoreTyx:Stringτ₁:Tyv:Tmhv:<{ ∅ / δ ⊢ v ⦂ τ₁ }>y:Stringa✝¹:Tya✝:Tmih:∀ (Γ : Context) (τ : Ty), <{ ~(x →ₚ τ₁ ; Γ) / δ ⊢ a✝ ⦂ τ }> → <{ Γ / δ ⊢ [~x := v] a✝ ⦂ τ }>Γ:Contextτ₁✝:Tyh:<{ ~(x →ₚ τ₁ ; y →ₚ a✝¹ ; Γ) / δ ⊢ a✝ ⦂ τ₁✝ }>h₁:¬x = y⊢ <{ Γ / δ ⊢ ~(if x = y then <{ λ ~y : a✝¹ . a✝ }> else <{ λ ~y : a✝¹ . [~x := v] a✝ }>) ⦂ a✝¹ → τ₁✝ }>neg δ:StoreTyx:Stringτ₁:Tyv:Tmhv:<{ ∅ / δ ⊢ v ⦂ τ₁ }>y:Stringa✝¹:Tya✝:Tmih:∀ (Γ : Context) (τ : Ty), <{ ~(x →ₚ τ₁ ; Γ) / δ ⊢ a✝ ⦂ τ }> → <{ Γ / δ ⊢ [~x := v] a✝ ⦂ τ }>Γ:Contextτ₁✝:Tyh:<{ ~(y →ₚ a✝¹ ; x →ₚ τ₁ ; Γ) / δ ⊢ a✝ ⦂ τ₁✝ }>h₁:¬x = y⊢ y ≠ x
· neg δ:StoreTyx:Stringτ₁:Tyv:Tmhv:<{ ∅ / δ ⊢ v ⦂ τ₁ }>y:Stringa✝¹:Tya✝:Tmih:∀ (Γ : Context) (τ : Ty), <{ ~(x →ₚ τ₁ ; Γ) / δ ⊢ a✝ ⦂ τ }> → <{ Γ / δ ⊢ [~x := v] a✝ ⦂ τ }>Γ:Contextτ₁✝:Tyh:<{ ~(x →ₚ τ₁ ; y →ₚ a✝¹ ; Γ) / δ ⊢ a✝ ⦂ τ₁✝ }>h₁:¬x = y⊢ <{ Γ / δ ⊢ ~(if x = y then <{ λ ~y : a✝¹ . a✝ }> else <{ λ ~y : a✝¹ . [~x := v] a✝ }>) ⦂ a✝¹ → τ₁✝ }> simp_all neg δ:StoreTyx:Stringτ₁:Tyv:Tmhv:<{ ∅ / δ ⊢ v ⦂ τ₁ }>y:Stringa✝¹:Tya✝:Tmih:∀ (Γ : Context) (τ : Ty), <{ ~(x →ₚ τ₁ ; Γ) / δ ⊢ a✝ ⦂ τ }> → <{ Γ / δ ⊢ [~x := v] a✝ ⦂ τ }>Γ:Contextτ₁✝:Tyh:<{ ~(x →ₚ τ₁ ; y →ₚ a✝¹ ; Γ) / δ ⊢ a✝ ⦂ τ₁✝ }>h₁:¬x = y⊢ <{ Γ / δ ⊢ λ ~y : a✝¹ . [~x := v] a✝ ⦂ a✝¹ → τ₁✝ }>; apply_rules using StlcRefTyping All goals completed! 🐙
· neg δ:StoreTyx:Stringτ₁:Tyv:Tmhv:<{ ∅ / δ ⊢ v ⦂ τ₁ }>y:Stringa✝¹:Tya✝:Tmih:∀ (Γ : Context) (τ : Ty), <{ ~(x →ₚ τ₁ ; Γ) / δ ⊢ a✝ ⦂ τ }> → <{ Γ / δ ⊢ [~x := v] a✝ ⦂ τ }>Γ:Contextτ₁✝:Tyh:<{ ~(y →ₚ a✝¹ ; x →ₚ τ₁ ; Γ) / δ ⊢ a✝ ⦂ τ₁✝ }>h₁:¬x = y⊢ y ≠ x lia All goals completed! 🐙
9.5.3.2. Assignment Preserves Store Typing
Next, we must show that replacing the contents of a cell in the
store with a new value of appropriate type does not change the
overall type of the store. (This is needed for the assign
rule.)
theorem assign_pres_store_typing {δ : StoreTy} {ρ : Store} {l : Nat} {t : Tm}
(hLen : l < ρ.length)
(hStoreTy : δ ⊢ ρ)
(hTy : <{ ∅ / δ ⊢ t ⦂ ~(δ[l]) }>) :
δ ⊢ ρ.set l t := by δ:StoreTyρ:Storel:Natt:TmhLen:l < List.length ρhStoreTy:δ ⊢ ρhTy:<{ ∅ / δ ⊢ t ⦂ ~δ[l] }>⊢ δ ⊢ List.set ρ l t
have ⟨h₁, h₂⟩ := hStoreTy δ:StoreTyρ:Storel:Natt:TmhLen:l < List.length ρhStoreTy:δ ⊢ ρhTy:<{ ∅ / δ ⊢ t ⦂ ~δ[l] }>h₁:List.length δ = List.length ρh₂:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>⊢ δ ⊢ List.set ρ l t
constructor left δ:StoreTyρ:Storel:Natt:TmhLen:l < List.length ρhStoreTy:δ ⊢ ρhTy:<{ ∅ / δ ⊢ t ⦂ ~δ[l] }>h₁:List.length δ = List.length ρh₂:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>⊢ List.length δ = (List.set ρ l t).lengthright δ:StoreTyρ:Storel:Natt:TmhLen:l < List.length ρhStoreTy:δ ⊢ ρhTy:<{ ∅ / δ ⊢ t ⦂ ~δ[l] }>h₁:List.length δ = List.length ρh₂:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>⊢ ∀ (l_1 : Nat), l_1 < (List.set ρ l t).length → <{ ∅ / δ ⊢ ~(List.set ρ l t)[l_1] ⦂ ~δ[l_1] }>
· left δ:StoreTyρ:Storel:Natt:TmhLen:l < List.length ρhStoreTy:δ ⊢ ρhTy:<{ ∅ / δ ⊢ t ⦂ ~δ[l] }>h₁:List.length δ = List.length ρh₂:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>⊢ List.length δ = (List.set ρ l t).length simp_all [List.length_set] All goals completed! 🐙
· right δ:StoreTyρ:Storel:Natt:TmhLen:l < List.length ρhStoreTy:δ ⊢ ρhTy:<{ ∅ / δ ⊢ t ⦂ ~δ[l] }>h₁:List.length δ = List.length ρh₂:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>⊢ ∀ (l_1 : Nat), l_1 < (List.set ρ l t).length → <{ ∅ / δ ⊢ ~(List.set ρ l t)[l_1] ⦂ ~δ[l_1] }> intro l' hLen' right δ:StoreTyρ:Storel:Natt:TmhLen:l < List.length ρhStoreTy:δ ⊢ ρhTy:<{ ∅ / δ ⊢ t ⦂ ~δ[l] }>h₁:List.length δ = List.length ρh₂:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>l':NathLen':l' < (List.set ρ l t).length⊢ <{ ∅ / δ ⊢ ~(List.set ρ l t)[l'] ⦂ ~δ[l'] }>
by_cases h₁ : l' = l pos δ:StoreTyρ:Storel:Natt:TmhLen:l < List.length ρhStoreTy:δ ⊢ ρhTy:<{ ∅ / δ ⊢ t ⦂ ~δ[l] }>h₁✝:List.length δ = List.length ρh₂:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>l':NathLen':l' < (List.set ρ l t).lengthh₁:l' = l⊢ <{ ∅ / δ ⊢ ~(List.set ρ l t)[l'] ⦂ ~δ[l'] }>neg δ:StoreTyρ:Storel:Natt:TmhLen:l < List.length ρhStoreTy:δ ⊢ ρhTy:<{ ∅ / δ ⊢ t ⦂ ~δ[l] }>h₁✝:List.length δ = List.length ρh₂:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>l':NathLen':l' < (List.set ρ l t).lengthh₁:¬l' = l⊢ <{ ∅ / δ ⊢ ~(List.set ρ l t)[l'] ⦂ ~δ[l'] }>
· pos δ:StoreTyρ:Storel:Natt:TmhLen:l < List.length ρhStoreTy:δ ⊢ ρhTy:<{ ∅ / δ ⊢ t ⦂ ~δ[l] }>h₁✝:List.length δ = List.length ρh₂:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>l':NathLen':l' < (List.set ρ l t).lengthh₁:l' = l⊢ <{ ∅ / δ ⊢ ~(List.set ρ l t)[l'] ⦂ ~δ[l'] }> subst_vars pos δ:StoreTyρ:Storet:TmhStoreTy:δ ⊢ ρh₁:List.length δ = List.length ρh₂:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>l':NathLen:l' < List.length ρhTy:<{ ∅ / δ ⊢ t ⦂ ~δ[l'] }>hLen':l' < (List.set ρ l' t).length⊢ <{ ∅ / δ ⊢ ~(List.set ρ l' t)[l'] ⦂ ~δ[l'] }>
rw [Store_get_set_eq pos δ:StoreTyρ:Storet:TmhStoreTy:δ ⊢ ρh₁:List.length δ = List.length ρh₂:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>l':NathLen:l' < List.length ρhTy:<{ ∅ / δ ⊢ t ⦂ ~δ[l'] }>hLen':l' < (List.set ρ l' t).length⊢ <{ ∅ / δ ⊢ t ⦂ ~δ[l'] }>pos.h δ:StoreTyρ:Storet:TmhStoreTy:δ ⊢ ρh₁:List.length δ = List.length ρh₂:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>l':NathLen:l' < List.length ρhTy:<{ ∅ / δ ⊢ t ⦂ ~δ[l'] }>hLen':l' < (List.set ρ l' t).length⊢ l' < List.length ρ] pos δ:StoreTyρ:Storet:TmhStoreTy:δ ⊢ ρh₁:List.length δ = List.length ρh₂:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>l':NathLen:l' < List.length ρhTy:<{ ∅ / δ ⊢ t ⦂ ~δ[l'] }>hLen':l' < (List.set ρ l' t).length⊢ <{ ∅ / δ ⊢ t ⦂ ~δ[l'] }>pos.h δ:StoreTyρ:Storet:TmhStoreTy:δ ⊢ ρh₁:List.length δ = List.length ρh₂:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>l':NathLen:l' < List.length ρhTy:<{ ∅ / δ ⊢ t ⦂ ~δ[l'] }>hLen':l' < (List.set ρ l' t).length⊢ l' < List.length ρ <;> pos δ:StoreTyρ:Storet:TmhStoreTy:δ ⊢ ρh₁:List.length δ = List.length ρh₂:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>l':NathLen:l' < List.length ρhTy:<{ ∅ / δ ⊢ t ⦂ ~δ[l'] }>hLen':l' < (List.set ρ l' t).length⊢ <{ ∅ / δ ⊢ t ⦂ ~δ[l'] }>pos.h δ:StoreTyρ:Storet:TmhStoreTy:δ ⊢ ρh₁:List.length δ = List.length ρh₂:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>l':NathLen:l' < List.length ρhTy:<{ ∅ / δ ⊢ t ⦂ ~δ[l'] }>hLen':l' < (List.set ρ l' t).length⊢ l' < List.length ρ assumption All goals completed! 🐙
· neg δ:StoreTyρ:Storel:Natt:TmhLen:l < List.length ρhStoreTy:δ ⊢ ρhTy:<{ ∅ / δ ⊢ t ⦂ ~δ[l] }>h₁✝:List.length δ = List.length ρh₂:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>l':NathLen':l' < (List.set ρ l t).lengthh₁:¬l' = l⊢ <{ ∅ / δ ⊢ ~(List.set ρ l t)[l'] ⦂ ~δ[l'] }> rw [Store_get_set_neq neg δ:StoreTyρ:Storel:Natt:TmhLen:l < List.length ρhStoreTy:δ ⊢ ρhTy:<{ ∅ / δ ⊢ t ⦂ ~δ[l] }>h₁✝:List.length δ = List.length ρh₂:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>l':NathLen':l' < (List.set ρ l t).lengthh₁:¬l' = l⊢ <{ ∅ / δ ⊢ ~ρ[l'] ⦂ ~δ[l'] }>neg.a δ:StoreTyρ:Storel:Natt:TmhLen:l < List.length ρhStoreTy:δ ⊢ ρhTy:<{ ∅ / δ ⊢ t ⦂ ~δ[l] }>h₁✝:List.length δ = List.length ρh₂:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>l':NathLen':l' < (List.set ρ l t).lengthh₁:¬l' = l⊢ l' ≠ l] neg δ:StoreTyρ:Storel:Natt:TmhLen:l < List.length ρhStoreTy:δ ⊢ ρhTy:<{ ∅ / δ ⊢ t ⦂ ~δ[l] }>h₁✝:List.length δ = List.length ρh₂:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>l':NathLen':l' < (List.set ρ l t).lengthh₁:¬l' = l⊢ <{ ∅ / δ ⊢ ~ρ[l'] ⦂ ~δ[l'] }>neg.a δ:StoreTyρ:Storel:Natt:TmhLen:l < List.length ρhStoreTy:δ ⊢ ρhTy:<{ ∅ / δ ⊢ t ⦂ ~δ[l] }>h₁✝:List.length δ = List.length ρh₂:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>l':NathLen':l' < (List.set ρ l t).lengthh₁:¬l' = l⊢ l' ≠ l <;> neg δ:StoreTyρ:Storel:Natt:TmhLen:l < List.length ρhStoreTy:δ ⊢ ρhTy:<{ ∅ / δ ⊢ t ⦂ ~δ[l] }>h₁✝:List.length δ = List.length ρh₂:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>l':NathLen':l' < (List.set ρ l t).lengthh₁:¬l' = l⊢ <{ ∅ / δ ⊢ ~ρ[l'] ⦂ ~δ[l'] }>neg.a δ:StoreTyρ:Storel:Natt:TmhLen:l < List.length ρhStoreTy:δ ⊢ ρhTy:<{ ∅ / δ ⊢ t ⦂ ~δ[l] }>h₁✝:List.length δ = List.length ρh₂:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>l':NathLen':l' < (List.set ρ l t).lengthh₁:¬l' = l⊢ l' ≠ l try assumption All goals completed! 🐙
apply h₂ neg δ:StoreTyρ:Storel:Natt:TmhLen:l < List.length ρhStoreTy:δ ⊢ ρhTy:<{ ∅ / δ ⊢ t ⦂ ~δ[l] }>h₁✝:List.length δ = List.length ρh₂:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>l':NathLen':l' < (List.set ρ l t).lengthh₁:¬l' = l⊢ l' < List.length ρ
simp_all [List.length_set] All goals completed! 🐙
9.5.3.3. Weakening for Stores
Finally, we need a lemma on store typings, stating that, if a store typing is extended with a new location, the extended one still allows us to assign the same types to the same terms as the original.
theorem store_weakening {Γ : Context} {δ δ' : StoreTy} {t : Tm} {τ : Ty}
(hExt : Extends δ' δ)
(hTy : <{ Γ / δ ⊢ t ⦂ τ }>) :
<{ Γ / δ' ⊢ t ⦂ τ }> := by Γ:Contextδ:StoreTyδ':StoreTyt:Tmτ:TyhExt:Extends δ' δhTy:<{ Γ / δ ⊢ t ⦂ τ }>⊢ <{ Γ / δ' ⊢ t ⦂ τ }>
induction hTy with (try (apply_rules using StlcRefTyping All goals completed! 🐙; done))
| loc_ h => loc_ Γ:Contextδ:StoreTyδ':StoreTyt:Tmτ:TyhExt:Extends δ' δΓ✝:Contextl✝:Nath:l✝ < List.length δ⊢ <{ Γ✝ / δ' ⊢ ~(Tm.loc l✝) ⦂ Ref ~δ[l✝] }>
rw [←extends_lookup loc_ Γ:Contextδ:StoreTyδ':StoreTyt:Tmτ:TyhExt:Extends δ' δΓ✝:Contextl✝:Nath:l✝ < List.length δ⊢ <{ Γ✝ / δ' ⊢ ~(Tm.loc l✝) ⦂ Ref ~?m.40[l✝] }>loc_.h₁ Γ:Contextδ:StoreTyδ':StoreTyt:Tmτ:TyhExt:Extends δ' δΓ✝:Contextl✝:Nath:l✝ < List.length δ⊢ l✝ < List.length δloc_.h₂ Γ:Contextδ:StoreTyδ':StoreTyt:Tmτ:TyhExt:Extends δ' δΓ✝:Contextl✝:Nath:l✝ < List.length δ⊢ Extends ?m.40 δΓ:Contextδ:StoreTyδ':StoreTyt:Tmτ:TyhExt:Extends δ' δΓ✝:Contextl✝:Nath:l✝ < List.length δ⊢ StoreTy] loc_ Γ:Contextδ:StoreTyδ':StoreTyt:Tmτ:TyhExt:Extends δ' δΓ✝:Contextl✝:Nath:l✝ < List.length δ⊢ <{ Γ✝ / δ' ⊢ ~(Tm.loc l✝) ⦂ Ref ~?m.40[l✝] }>loc_.h₁ Γ:Contextδ:StoreTyδ':StoreTyt:Tmτ:TyhExt:Extends δ' δΓ✝:Contextl✝:Nath:l✝ < List.length δ⊢ l✝ < List.length δloc_.h₂ Γ:Contextδ:StoreTyδ':StoreTyt:Tmτ:TyhExt:Extends δ' δΓ✝:Contextl✝:Nath:l✝ < List.length δ⊢ Extends ?m.40 δΓ:Contextδ:StoreTyδ':StoreTyt:Tmτ:TyhExt:Extends δ' δΓ✝:Contextl✝:Nath:l✝ < List.length δ⊢ StoreTy <;> loc_ Γ:Contextδ:StoreTyδ':StoreTyt:Tmτ:TyhExt:Extends δ' δΓ✝:Contextl✝:Nath:l✝ < List.length δ⊢ <{ Γ✝ / δ' ⊢ ~(Tm.loc l✝) ⦂ Ref ~?m.40[l✝] }>loc_.h₁ Γ:Contextδ:StoreTyδ':StoreTyt:Tmτ:TyhExt:Extends δ' δΓ✝:Contextl✝:Nath:l✝ < List.length δ⊢ l✝ < List.length δloc_.h₂ Γ:Contextδ:StoreTyδ':StoreTyt:Tmτ:TyhExt:Extends δ' δΓ✝:Contextl✝:Nath:l✝ < List.length δ⊢ Extends ?m.40 δΓ:Contextδ:StoreTyδ':StoreTyt:Tmτ:TyhExt:Extends δ' δΓ✝:Contextl✝:Nath:l✝ < List.length δ⊢ StoreTy try assumption All goals completed! 🐙
apply HasType.loc_ loc_ Γ:Contextδ:StoreTyδ':StoreTyt:Tmτ:TyhExt:Extends δ' δΓ✝:Contextl✝:Nath:l✝ < List.length δ⊢ l✝ < List.length δ'
apply length_extends loc_.h₁ Γ:Contextδ:StoreTyδ':StoreTyt:Tmτ:TyhExt:Extends δ' δΓ✝:Contextl✝:Nath:l✝ < List.length δ⊢ l✝ < List.length ?loc_.δloc_.h₂ Γ:Contextδ:StoreTyδ':StoreTyt:Tmτ:TyhExt:Extends δ' δΓ✝:Contextl✝:Nath:l✝ < List.length δ⊢ Extends δ' ?loc_.δloc_.δ Γ:Contextδ:StoreTyδ':StoreTyt:Tmτ:TyhExt:Extends δ' δΓ✝:Contextl✝:Nath:l✝ < List.length δ⊢ StoreTy <;> loc_.h₁ Γ:Contextδ:StoreTyδ':StoreTyt:Tmτ:TyhExt:Extends δ' δΓ✝:Contextl✝:Nath:l✝ < List.length δ⊢ l✝ < List.length ?loc_.δloc_.h₂ Γ:Contextδ:StoreTyδ':StoreTyt:Tmτ:TyhExt:Extends δ' δΓ✝:Contextl✝:Nath:l✝ < List.length δ⊢ Extends δ' ?loc_.δloc_.δ Γ:Contextδ:StoreTyδ':StoreTyt:Tmτ:TyhExt:Extends δ' δΓ✝:Contextl✝:Nath:l✝ < List.length δ⊢ StoreTy assumption All goals completed! 🐙
We can use the store_weakening lemma to prove that if a store is
well typed with respect to a store typing, then the store extended
with a new term τ will still be well typed with respect to the
store typing extended with τ's type.
theorem store_well_typed_app {δ : StoreTy} {ρ : Store} {t₁ : Tm} {τ₁ : Ty}
(hStoreTy : δ ⊢ ρ)
(hTy : <{ ∅ / δ ⊢ t₁ ⦂ τ₁ }>) :
(δ.concat τ₁) ⊢ (ρ.concat t₁) := by δ:StoreTyρ:Storet₁:Tmτ₁:TyhStoreTy:δ ⊢ ρhTy:<{ ∅ / δ ⊢ t₁ ⦂ τ₁ }>⊢ List.concat δ τ₁ ⊢ List.concat ρ t₁
have ⟨h₁, h₂⟩ := hStoreTy δ:StoreTyρ:Storet₁:Tmτ₁:TyhStoreTy:δ ⊢ ρhTy:<{ ∅ / δ ⊢ t₁ ⦂ τ₁ }>h₁:List.length δ = List.length ρh₂:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>⊢ List.concat δ τ₁ ⊢ List.concat ρ t₁
simp_all only [List.concat_eq_append] δ:StoreTyρ:Storet₁:Tmτ₁:TyhStoreTy:δ ⊢ ρhTy:<{ ∅ / δ ⊢ t₁ ⦂ τ₁ }>h₁:List.length δ = List.length ρh₂:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>⊢ δ ++ [τ₁] ⊢ ρ ++ [t₁]
constructor left δ:StoreTyρ:Storet₁:Tmτ₁:TyhStoreTy:δ ⊢ ρhTy:<{ ∅ / δ ⊢ t₁ ⦂ τ₁ }>h₁:List.length δ = List.length ρh₂:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>⊢ (δ ++ [τ₁]).length = (ρ ++ [t₁]).lengthright δ:StoreTyρ:Storet₁:Tmτ₁:TyhStoreTy:δ ⊢ ρhTy:<{ ∅ / δ ⊢ t₁ ⦂ τ₁ }>h₁:List.length δ = List.length ρh₂:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>⊢ ∀ (l : Nat), l < (ρ ++ [t₁]).length → <{ ∅ / (δ ++ [τ₁]) ⊢ ~(ρ ++ [t₁])[l] ⦂ ~(δ ++ [τ₁])[l] }>
· left δ:StoreTyρ:Storet₁:Tmτ₁:TyhStoreTy:δ ⊢ ρhTy:<{ ∅ / δ ⊢ t₁ ⦂ τ₁ }>h₁:List.length δ = List.length ρh₂:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>⊢ (δ ++ [τ₁]).length = (ρ ++ [t₁]).length simp_all All goals completed! 🐙
· right δ:StoreTyρ:Storet₁:Tmτ₁:TyhStoreTy:δ ⊢ ρhTy:<{ ∅ / δ ⊢ t₁ ⦂ τ₁ }>h₁:List.length δ = List.length ρh₂:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>⊢ ∀ (l : Nat), l < (ρ ++ [t₁]).length → <{ ∅ / (δ ++ [τ₁]) ⊢ ~(ρ ++ [t₁])[l] ⦂ ~(δ ++ [τ₁])[l] }> simp_all only [List.length_append, List.length_cons, List.length_nil, Nat.zero_add] right δ:StoreTyρ:Storet₁:Tmτ₁:TyhStoreTy:δ ⊢ ρhTy:<{ ∅ / δ ⊢ t₁ ⦂ τ₁ }>h₁:List.length δ = List.length ρh₂:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>⊢ ∀ (l : Nat), l < List.length ρ + 1 → <{ ∅ / (δ ++ [τ₁]) ⊢ ~(ρ ++ [t₁])[l] ⦂ ~(δ ++ [τ₁])[l] }>
intro l hl right δ:StoreTyρ:Storet₁:Tmτ₁:TyhStoreTy:δ ⊢ ρhTy:<{ ∅ / δ ⊢ t₁ ⦂ τ₁ }>h₁:List.length δ = List.length ρh₂:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>l:Nathl:l < List.length ρ + 1⊢ <{ ∅ / (δ ++ [τ₁]) ⊢ ~(ρ ++ [t₁])[l] ⦂ ~(δ ++ [τ₁])[l] }>
inversion hl with
| refl => refl δ:StoreTyρ:Storet₁:Tmτ₁:TyhStoreTy:δ ⊢ ρhTy:<{ ∅ / δ ⊢ t₁ ⦂ τ₁ }>h₁:List.length δ = List.length ρh₂:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>⊢ <{ ∅ / (δ ++ [τ₁]) ⊢ ~(ρ ++ [t₁])[List.length ρ] ⦂ ~(δ ++ [τ₁])[List.length ρ] }>
apply store_weakening refl.hExt δ:StoreTyρ:Storet₁:Tmτ₁:TyhStoreTy:δ ⊢ ρhTy:<{ ∅ / δ ⊢ t₁ ⦂ τ₁ }>h₁:List.length δ = List.length ρh₂:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>⊢ Extends (δ ++ [τ₁]) ?refl.δrefl.hTy δ:StoreTyρ:Storet₁:Tmτ₁:TyhStoreTy:δ ⊢ ρhTy:<{ ∅ / δ ⊢ t₁ ⦂ τ₁ }>h₁:List.length δ = List.length ρh₂:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>⊢ <{ ∅ / ?refl.δ ⊢ ~(ρ ++ [t₁])[List.length ρ] ⦂ ~(δ ++ [τ₁])[List.length ρ] }>refl.δ δ:StoreTyρ:Storet₁:Tmτ₁:TyhStoreTy:δ ⊢ ρhTy:<{ ∅ / δ ⊢ t₁ ⦂ τ₁ }>h₁:List.length δ = List.length ρh₂:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>⊢ StoreTy <;> refl.hExt δ:StoreTyρ:Storet₁:Tmτ₁:TyhStoreTy:δ ⊢ ρhTy:<{ ∅ / δ ⊢ t₁ ⦂ τ₁ }>h₁:List.length δ = List.length ρh₂:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>⊢ Extends (δ ++ [τ₁]) ?refl.δrefl.hTy δ:StoreTyρ:Storet₁:Tmτ₁:TyhStoreTy:δ ⊢ ρhTy:<{ ∅ / δ ⊢ t₁ ⦂ τ₁ }>h₁:List.length δ = List.length ρh₂:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>⊢ <{ ∅ / ?refl.δ ⊢ ~(ρ ++ [t₁])[List.length ρ] ⦂ ~(δ ++ [τ₁])[List.length ρ] }>refl.δ δ:StoreTyρ:Storet₁:Tmτ₁:TyhStoreTy:δ ⊢ ρhTy:<{ ∅ / δ ⊢ t₁ ⦂ τ₁ }>h₁:List.length δ = List.length ρh₂:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>⊢ StoreTy try assumption All goals completed! 🐙
apply extends_app refl.hTy δ:StoreTyρ:Storet₁:Tmτ₁:TyhStoreTy:δ ⊢ ρhTy:<{ ∅ / δ ⊢ t₁ ⦂ τ₁ }>h₁:List.length δ = List.length ρh₂:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>⊢ <{ ∅ / δ ⊢ ~(ρ ++ [t₁])[List.length ρ] ⦂ ~(δ ++ [τ₁])[List.length ρ] }>
simp_all [MyGetElem.getElem] All goals completed! 🐙
| step hl => step δ:StoreTyρ:Storet₁:Tmτ₁:TyhStoreTy:δ ⊢ ρhTy:<{ ∅ / δ ⊢ t₁ ⦂ τ₁ }>h₁:List.length δ = List.length ρh₂:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>l:Nathl:l.succ.le (List.length ρ)⊢ <{ ∅ / (δ ++ [τ₁]) ⊢ ~(ρ ++ [t₁])[l] ⦂ ~(δ ++ [τ₁])[l] }>
apply store_weakening step.hExt δ:StoreTyρ:Storet₁:Tmτ₁:TyhStoreTy:δ ⊢ ρhTy:<{ ∅ / δ ⊢ t₁ ⦂ τ₁ }>h₁:List.length δ = List.length ρh₂:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>l:Nathl:l.succ.le (List.length ρ)⊢ Extends (δ ++ [τ₁]) ?step.δstep.hTy δ:StoreTyρ:Storet₁:Tmτ₁:TyhStoreTy:δ ⊢ ρhTy:<{ ∅ / δ ⊢ t₁ ⦂ τ₁ }>h₁:List.length δ = List.length ρh₂:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>l:Nathl:l.succ.le (List.length ρ)⊢ <{ ∅ / ?step.δ ⊢ ~(ρ ++ [t₁])[l] ⦂ ~(δ ++ [τ₁])[l] }>step.δ δ:StoreTyρ:Storet₁:Tmτ₁:TyhStoreTy:δ ⊢ ρhTy:<{ ∅ / δ ⊢ t₁ ⦂ τ₁ }>h₁:List.length δ = List.length ρh₂:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>l:Nathl:l.succ.le (List.length ρ)⊢ StoreTy <;> step.hExt δ:StoreTyρ:Storet₁:Tmτ₁:TyhStoreTy:δ ⊢ ρhTy:<{ ∅ / δ ⊢ t₁ ⦂ τ₁ }>h₁:List.length δ = List.length ρh₂:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>l:Nathl:l.succ.le (List.length ρ)⊢ Extends (δ ++ [τ₁]) ?step.δstep.hTy δ:StoreTyρ:Storet₁:Tmτ₁:TyhStoreTy:δ ⊢ ρhTy:<{ ∅ / δ ⊢ t₁ ⦂ τ₁ }>h₁:List.length δ = List.length ρh₂:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>l:Nathl:l.succ.le (List.length ρ)⊢ <{ ∅ / ?step.δ ⊢ ~(ρ ++ [t₁])[l] ⦂ ~(δ ++ [τ₁])[l] }>step.δ δ:StoreTyρ:Storet₁:Tmτ₁:TyhStoreTy:δ ⊢ ρhTy:<{ ∅ / δ ⊢ t₁ ⦂ τ₁ }>h₁:List.length δ = List.length ρh₂:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>l:Nathl:l.succ.le (List.length ρ)⊢ StoreTy try assumption All goals completed! 🐙
· step.hExt δ:StoreTyρ:Storet₁:Tmτ₁:TyhStoreTy:δ ⊢ ρhTy:<{ ∅ / δ ⊢ t₁ ⦂ τ₁ }>h₁:List.length δ = List.length ρh₂:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>l:Nathl:l.succ.le (List.length ρ)⊢ Extends (δ ++ [τ₁]) δ apply extends_app All goals completed! 🐙
· step.hTy δ:StoreTyρ:Storet₁:Tmτ₁:TyhStoreTy:δ ⊢ ρhTy:<{ ∅ / δ ⊢ t₁ ⦂ τ₁ }>h₁:List.length δ = List.length ρh₂:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>l:Nathl:l.succ.le (List.length ρ)⊢ <{ ∅ / δ ⊢ ~(ρ ++ [t₁])[l] ⦂ ~(δ ++ [τ₁])[l] }> have hl' : l < ρ.length := by δ:StoreTyρ:Storet₁:Tmτ₁:TyhStoreTy:δ ⊢ ρhTy:<{ ∅ / δ ⊢ t₁ ⦂ τ₁ }>⊢ List.concat δ τ₁ ⊢ List.concat ρ t₁ lia step.hTy δ:StoreTyρ:Storet₁:Tmτ₁:TyhStoreTy:δ ⊢ ρhTy:<{ ∅ / δ ⊢ t₁ ⦂ τ₁ }>h₁:List.length δ = List.length ρh₂:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>l:Nathl:l.succ.le (List.length ρ)hl':l < List.length ρ⊢ <{ ∅ / δ ⊢ ~(ρ ++ [t₁])[l] ⦂ ~(δ ++ [τ₁])[l] }>
simp_all [MyGetElem.getElem, List.getElem?_append_left] All goals completed! 🐙
9.5.3.4. Preservation!
Now that we've got everything set up right, the proof of preservation is actually quite straightforward:
theorem preservation {δ : StoreTy} {t t' : Tm} {τ : Ty} {ρ ρ' : Store}
(hTy : <{ ∅ / δ ⊢ t ⦂ τ }>)
(hStoreTy : δ ⊢ ρ)
(hEval : t / ρ ⟶ t' / ρ') :
∃ δ', Extends δ' δ ∧ (<{ ∅ / δ' ⊢ t' ⦂ τ }>) ∧ (δ' ⊢ ρ') := by δ:StoreTyt:Tmt':Tmτ:Tyρ:Storeρ':StorehTy:<{ ∅ / δ ⊢ t ⦂ τ }>hStoreTy:δ ⊢ ρhEval:t / ρ ⟶ t' / ρ'⊢ ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ }> ∧ δ' ⊢ ρ'
generalize heq : (∅ : Context) = Γ at hTy δ:StoreTyt:Tmt':Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρhEval:t / ρ ⟶ t' / ρ'Γ:Contextheq:∅ = ΓhTy:<{ Γ / δ ⊢ t ⦂ τ }>⊢ ∃ δ', Extends δ' δ ∧ <{ Γ / δ' ⊢ t' ⦂ τ }> ∧ δ' ⊢ ρ'
-- discharge the goals where `t` doesn't step
induction hTy generalizing t' with (subst_vars loc_ δ:StoreTyt:Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρΓ:Contextl✝:Nath✝:l✝ < List.length δt':TmhEval:Tm.loc l✝ / ρ ⟶ t' / ρ'⊢ ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Ref ~δ[l✝] }> ∧ δ' ⊢ ρ'; try (inversion hEval All goals completed! 🐙; done All goals completed! 🐙))
| app h₁ h₂ ih₁ ih₂ => app δ:StoreTyt:Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρΓ:Contextτ₁✝:Tyτ₂✝:Tyt₁✝:Tmt₂✝:Tmt':TmhEval:<{ t₁✝ t₂✝ }> / ρ ⟶ t' / ρ'h₁:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₂✝ → τ₁✝ }>h₂:<{ ∅ / δ ⊢ t₂✝ ⦂ τ₂✝ }>ih₁:∀ {t' : Tm}, t₁✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₂✝ → τ₁✝ }> ∧ δ' ⊢ ρ'ih₂:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₂✝ }> ∧ δ' ⊢ ρ'⊢ ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₁✝ }> ∧ δ' ⊢ ρ'
inversion hEval with
| appAbs => appAbs δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextτ₁✝:Tyτ₂✝¹:Tyt₂✝:Tmh₂:<{ ∅ / δ ⊢ t₂✝ ⦂ τ₂✝ }>x✝:Stringτ₂✝:Tyt₁✝:Tmh₁:<{ ∅ / δ ⊢ λ ~x✝ : τ₂✝ . t₁✝ ⦂ τ₂✝¹ → τ₁✝ }>h✝:t₂✝.IsValueih₂:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₂✝¹ }> ∧ δ' ⊢ ρih₁:∀ {t' : Tm}, <{ λ ~x✝ : τ₂✝ . t₁✝ }> / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₂✝¹ → τ₁✝ }> ∧ δ' ⊢ ρ⊢ ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ [~x✝ := t₂✝] t₁✝ ⦂ τ₁✝ }> ∧ δ' ⊢ ρ
inversion h₁ with | abs h => abs δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextτ₁✝:Tyτ₂✝:Tyt₂✝:Tmh₂:<{ ∅ / δ ⊢ t₂✝ ⦂ τ₂✝ }>x✝:Stringt₁✝:Tmh✝:t₂✝.IsValueih₂:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₂✝¹ }> ∧ δ' ⊢ ρih₁:∀ {t' : Tm}, <{ λ ~x✝ : τ₂✝ . t₁✝ }> / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₂✝ → τ₁✝ }> ∧ δ' ⊢ ρh:<{ ~(x✝ →ₚ τ₂✝) / δ ⊢ t₁✝ ⦂ τ₁✝ }>⊢ ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ [~x✝ := t₂✝] t₁✝ ⦂ τ₁✝ }> ∧ δ' ⊢ ρ
exists δ abs δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextτ₁✝:Tyτ₂✝:Tyt₂✝:Tmh₂:<{ ∅ / δ ⊢ t₂✝ ⦂ τ₂✝ }>x✝:Stringt₁✝:Tmh✝:t₂✝.IsValueih₂:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₂✝¹ }> ∧ δ' ⊢ ρih₁:∀ {t' : Tm}, <{ λ ~x✝ : τ₂✝ . t₁✝ }> / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₂✝ → τ₁✝ }> ∧ δ' ⊢ ρh:<{ ~(x✝ →ₚ τ₂✝) / δ ⊢ t₁✝ ⦂ τ₁✝ }>⊢ Extends δ δ ∧ <{ ∅ / δ ⊢ [~x✝ := t₂✝] t₁✝ ⦂ τ₁✝ }> ∧ δ ⊢ ρ; constructor abs.left δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextτ₁✝:Tyτ₂✝:Tyt₂✝:Tmh₂:<{ ∅ / δ ⊢ t₂✝ ⦂ τ₂✝ }>x✝:Stringt₁✝:Tmh✝:t₂✝.IsValueih₂:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₂✝¹ }> ∧ δ' ⊢ ρih₁:∀ {t' : Tm}, <{ λ ~x✝ : τ₂✝ . t₁✝ }> / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₂✝ → τ₁✝ }> ∧ δ' ⊢ ρh:<{ ~(x✝ →ₚ τ₂✝) / δ ⊢ t₁✝ ⦂ τ₁✝ }>⊢ Extends δ δabs.right δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextτ₁✝:Tyτ₂✝:Tyt₂✝:Tmh₂:<{ ∅ / δ ⊢ t₂✝ ⦂ τ₂✝ }>x✝:Stringt₁✝:Tmh✝:t₂✝.IsValueih₂:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₂✝¹ }> ∧ δ' ⊢ ρih₁:∀ {t' : Tm}, <{ λ ~x✝ : τ₂✝ . t₁✝ }> / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₂✝ → τ₁✝ }> ∧ δ' ⊢ ρh:<{ ~(x✝ →ₚ τ₂✝) / δ ⊢ t₁✝ ⦂ τ₁✝ }>⊢ <{ ∅ / δ ⊢ [~x✝ := t₂✝] t₁✝ ⦂ τ₁✝ }> ∧ δ ⊢ ρ
apply extends_refl abs.right δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextτ₁✝:Tyτ₂✝:Tyt₂✝:Tmh₂:<{ ∅ / δ ⊢ t₂✝ ⦂ τ₂✝ }>x✝:Stringt₁✝:Tmh✝:t₂✝.IsValueih₂:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₂✝¹ }> ∧ δ' ⊢ ρih₁:∀ {t' : Tm}, <{ λ ~x✝ : τ₂✝ . t₁✝ }> / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₂✝ → τ₁✝ }> ∧ δ' ⊢ ρh:<{ ~(x✝ →ₚ τ₂✝) / δ ⊢ t₁✝ ⦂ τ₁✝ }>⊢ <{ ∅ / δ ⊢ [~x✝ := t₂✝] t₁✝ ⦂ τ₁✝ }> ∧ δ ⊢ ρ; constructor abs.right.left δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextτ₁✝:Tyτ₂✝:Tyt₂✝:Tmh₂:<{ ∅ / δ ⊢ t₂✝ ⦂ τ₂✝ }>x✝:Stringt₁✝:Tmh✝:t₂✝.IsValueih₂:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₂✝¹ }> ∧ δ' ⊢ ρih₁:∀ {t' : Tm}, <{ λ ~x✝ : τ₂✝ . t₁✝ }> / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₂✝ → τ₁✝ }> ∧ δ' ⊢ ρh:<{ ~(x✝ →ₚ τ₂✝) / δ ⊢ t₁✝ ⦂ τ₁✝ }>⊢ <{ ∅ / δ ⊢ [~x✝ := t₂✝] t₁✝ ⦂ τ₁✝ }>abs.right.right δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextτ₁✝:Tyτ₂✝:Tyt₂✝:Tmh₂:<{ ∅ / δ ⊢ t₂✝ ⦂ τ₂✝ }>x✝:Stringt₁✝:Tmh✝:t₂✝.IsValueih₂:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₂✝¹ }> ∧ δ' ⊢ ρih₁:∀ {t' : Tm}, <{ λ ~x✝ : τ₂✝ . t₁✝ }> / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₂✝ → τ₁✝ }> ∧ δ' ⊢ ρh:<{ ~(x✝ →ₚ τ₂✝) / δ ⊢ t₁✝ ⦂ τ₁✝ }>⊢ δ ⊢ ρ
apply_rules [substitution_preserves_typing, extends_refl] using StlcRefTyping abs.right.right δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextτ₁✝:Tyτ₂✝:Tyt₂✝:Tmh₂:<{ ∅ / δ ⊢ t₂✝ ⦂ τ₂✝ }>x✝:Stringt₁✝:Tmh✝:t₂✝.IsValueih₂:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₂✝¹ }> ∧ δ' ⊢ ρih₁:∀ {t' : Tm}, <{ λ ~x✝ : τ₂✝ . t₁✝ }> / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₂✝ → τ₁✝ }> ∧ δ' ⊢ ρh:<{ ~(x✝ →ₚ τ₂✝) / δ ⊢ t₁✝ ⦂ τ₁✝ }>⊢ δ ⊢ ρ
assumption All goals completed! 🐙
| app₁ hs => app₁ δ:StoreTyt:Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρΓ:Contextτ₁✝:Tyτ₂✝:Tyt₁✝:Tmt₂✝:Tmh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₂✝ → τ₁✝ }>h₂:<{ ∅ / δ ⊢ t₂✝ ⦂ τ₂✝ }>ih₁:∀ {t' : Tm}, t₁✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₂✝ → τ₁✝ }> ∧ δ' ⊢ ρ'ih₂:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₂✝ }> ∧ δ' ⊢ ρ't₁'✝:Tmhs:t₁✝ / ρ ⟶ t₁'✝ / ρ'⊢ ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t₁'✝ t₂✝ ⦂ τ₁✝ }> ∧ δ' ⊢ ρ'
have ⟨δ', hExt, hTy', hStoreTy'⟩ := ih₁ hs rfl app₁ δ:StoreTyt:Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρΓ:Contextτ₁✝:Tyτ₂✝:Tyt₁✝:Tmt₂✝:Tmh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₂✝ → τ₁✝ }>h₂:<{ ∅ / δ ⊢ t₂✝ ⦂ τ₂✝ }>ih₁:∀ {t' : Tm}, t₁✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₂✝ → τ₁✝ }> ∧ δ' ⊢ ρ'ih₂:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₂✝ }> ∧ δ' ⊢ ρ't₁'✝:Tmhs:t₁✝ / ρ ⟶ t₁'✝ / ρ'δ':StoreTyhExt:Extends δ' δhTy':<{ ∅ / δ' ⊢ t₁'✝ ⦂ τ₂✝ → τ₁✝ }>hStoreTy':δ' ⊢ ρ'⊢ ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t₁'✝ t₂✝ ⦂ τ₁✝ }> ∧ δ' ⊢ ρ'
exists δ' app₁ δ:StoreTyt:Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρΓ:Contextτ₁✝:Tyτ₂✝:Tyt₁✝:Tmt₂✝:Tmh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₂✝ → τ₁✝ }>h₂:<{ ∅ / δ ⊢ t₂✝ ⦂ τ₂✝ }>ih₁:∀ {t' : Tm}, t₁✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₂✝ → τ₁✝ }> ∧ δ' ⊢ ρ'ih₂:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₂✝ }> ∧ δ' ⊢ ρ't₁'✝:Tmhs:t₁✝ / ρ ⟶ t₁'✝ / ρ'δ':StoreTyhExt:Extends δ' δhTy':<{ ∅ / δ' ⊢ t₁'✝ ⦂ τ₂✝ → τ₁✝ }>hStoreTy':δ' ⊢ ρ'⊢ Extends δ' δ ∧ <{ ∅ / δ' ⊢ t₁'✝ t₂✝ ⦂ τ₁✝ }> ∧ δ' ⊢ ρ'; constructor app₁.left δ:StoreTyt:Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρΓ:Contextτ₁✝:Tyτ₂✝:Tyt₁✝:Tmt₂✝:Tmh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₂✝ → τ₁✝ }>h₂:<{ ∅ / δ ⊢ t₂✝ ⦂ τ₂✝ }>ih₁:∀ {t' : Tm}, t₁✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₂✝ → τ₁✝ }> ∧ δ' ⊢ ρ'ih₂:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₂✝ }> ∧ δ' ⊢ ρ't₁'✝:Tmhs:t₁✝ / ρ ⟶ t₁'✝ / ρ'δ':StoreTyhExt:Extends δ' δhTy':<{ ∅ / δ' ⊢ t₁'✝ ⦂ τ₂✝ → τ₁✝ }>hStoreTy':δ' ⊢ ρ'⊢ Extends δ' δapp₁.right δ:StoreTyt:Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρΓ:Contextτ₁✝:Tyτ₂✝:Tyt₁✝:Tmt₂✝:Tmh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₂✝ → τ₁✝ }>h₂:<{ ∅ / δ ⊢ t₂✝ ⦂ τ₂✝ }>ih₁:∀ {t' : Tm}, t₁✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₂✝ → τ₁✝ }> ∧ δ' ⊢ ρ'ih₂:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₂✝ }> ∧ δ' ⊢ ρ't₁'✝:Tmhs:t₁✝ / ρ ⟶ t₁'✝ / ρ'δ':StoreTyhExt:Extends δ' δhTy':<{ ∅ / δ' ⊢ t₁'✝ ⦂ τ₂✝ → τ₁✝ }>hStoreTy':δ' ⊢ ρ'⊢ <{ ∅ / δ' ⊢ t₁'✝ t₂✝ ⦂ τ₁✝ }> ∧ δ' ⊢ ρ'
assumption app₁.right δ:StoreTyt:Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρΓ:Contextτ₁✝:Tyτ₂✝:Tyt₁✝:Tmt₂✝:Tmh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₂✝ → τ₁✝ }>h₂:<{ ∅ / δ ⊢ t₂✝ ⦂ τ₂✝ }>ih₁:∀ {t' : Tm}, t₁✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₂✝ → τ₁✝ }> ∧ δ' ⊢ ρ'ih₂:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₂✝ }> ∧ δ' ⊢ ρ't₁'✝:Tmhs:t₁✝ / ρ ⟶ t₁'✝ / ρ'δ':StoreTyhExt:Extends δ' δhTy':<{ ∅ / δ' ⊢ t₁'✝ ⦂ τ₂✝ → τ₁✝ }>hStoreTy':δ' ⊢ ρ'⊢ <{ ∅ / δ' ⊢ t₁'✝ t₂✝ ⦂ τ₁✝ }> ∧ δ' ⊢ ρ'; constructor app₁.right.left δ:StoreTyt:Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρΓ:Contextτ₁✝:Tyτ₂✝:Tyt₁✝:Tmt₂✝:Tmh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₂✝ → τ₁✝ }>h₂:<{ ∅ / δ ⊢ t₂✝ ⦂ τ₂✝ }>ih₁:∀ {t' : Tm}, t₁✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₂✝ → τ₁✝ }> ∧ δ' ⊢ ρ'ih₂:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₂✝ }> ∧ δ' ⊢ ρ't₁'✝:Tmhs:t₁✝ / ρ ⟶ t₁'✝ / ρ'δ':StoreTyhExt:Extends δ' δhTy':<{ ∅ / δ' ⊢ t₁'✝ ⦂ τ₂✝ → τ₁✝ }>hStoreTy':δ' ⊢ ρ'⊢ <{ ∅ / δ' ⊢ t₁'✝ t₂✝ ⦂ τ₁✝ }>app₁.right.right δ:StoreTyt:Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρΓ:Contextτ₁✝:Tyτ₂✝:Tyt₁✝:Tmt₂✝:Tmh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₂✝ → τ₁✝ }>h₂:<{ ∅ / δ ⊢ t₂✝ ⦂ τ₂✝ }>ih₁:∀ {t' : Tm}, t₁✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₂✝ → τ₁✝ }> ∧ δ' ⊢ ρ'ih₂:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₂✝ }> ∧ δ' ⊢ ρ't₁'✝:Tmhs:t₁✝ / ρ ⟶ t₁'✝ / ρ'δ':StoreTyhExt:Extends δ' δhTy':<{ ∅ / δ' ⊢ t₁'✝ ⦂ τ₂✝ → τ₁✝ }>hStoreTy':δ' ⊢ ρ'⊢ δ' ⊢ ρ'
solve_by_elim [store_weakening] using StlcRefTyping app₁.right.right δ:StoreTyt:Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρΓ:Contextτ₁✝:Tyτ₂✝:Tyt₁✝:Tmt₂✝:Tmh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₂✝ → τ₁✝ }>h₂:<{ ∅ / δ ⊢ t₂✝ ⦂ τ₂✝ }>ih₁:∀ {t' : Tm}, t₁✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₂✝ → τ₁✝ }> ∧ δ' ⊢ ρ'ih₂:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₂✝ }> ∧ δ' ⊢ ρ't₁'✝:Tmhs:t₁✝ / ρ ⟶ t₁'✝ / ρ'δ':StoreTyhExt:Extends δ' δhTy':<{ ∅ / δ' ⊢ t₁'✝ ⦂ τ₂✝ → τ₁✝ }>hStoreTy':δ' ⊢ ρ'⊢ δ' ⊢ ρ'
assumption All goals completed! 🐙
| app₂ _ hs => app₂ δ:StoreTyt:Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρΓ:Contextτ₁✝:Tyτ₂✝:Tyt₁✝:Tmt₂✝:Tmh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₂✝ → τ₁✝ }>h₂:<{ ∅ / δ ⊢ t₂✝ ⦂ τ₂✝ }>ih₁:∀ {t' : Tm}, t₁✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₂✝ → τ₁✝ }> ∧ δ' ⊢ ρ'ih₂:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₂✝ }> ∧ δ' ⊢ ρ't₂'✝:Tmh₁✝:t₁✝.IsValuehs:t₂✝ / ρ ⟶ t₂'✝ / ρ'⊢ ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t₁✝ t₂'✝ ⦂ τ₁✝ }> ∧ δ' ⊢ ρ'
have ⟨δ', hExt, hTy', hStoreTy'⟩ := ih₂ hs rfl app₂ δ:StoreTyt:Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρΓ:Contextτ₁✝:Tyτ₂✝:Tyt₁✝:Tmt₂✝:Tmh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₂✝ → τ₁✝ }>h₂:<{ ∅ / δ ⊢ t₂✝ ⦂ τ₂✝ }>ih₁:∀ {t' : Tm}, t₁✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₂✝ → τ₁✝ }> ∧ δ' ⊢ ρ'ih₂:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₂✝ }> ∧ δ' ⊢ ρ't₂'✝:Tmh₁✝:t₁✝.IsValuehs:t₂✝ / ρ ⟶ t₂'✝ / ρ'δ':StoreTyhExt:Extends δ' δhTy':<{ ∅ / δ' ⊢ t₂'✝ ⦂ τ₂✝ }>hStoreTy':δ' ⊢ ρ'⊢ ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t₁✝ t₂'✝ ⦂ τ₁✝ }> ∧ δ' ⊢ ρ'
exists δ' app₂ δ:StoreTyt:Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρΓ:Contextτ₁✝:Tyτ₂✝:Tyt₁✝:Tmt₂✝:Tmh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₂✝ → τ₁✝ }>h₂:<{ ∅ / δ ⊢ t₂✝ ⦂ τ₂✝ }>ih₁:∀ {t' : Tm}, t₁✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₂✝ → τ₁✝ }> ∧ δ' ⊢ ρ'ih₂:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₂✝ }> ∧ δ' ⊢ ρ't₂'✝:Tmh₁✝:t₁✝.IsValuehs:t₂✝ / ρ ⟶ t₂'✝ / ρ'δ':StoreTyhExt:Extends δ' δhTy':<{ ∅ / δ' ⊢ t₂'✝ ⦂ τ₂✝ }>hStoreTy':δ' ⊢ ρ'⊢ Extends δ' δ ∧ <{ ∅ / δ' ⊢ t₁✝ t₂'✝ ⦂ τ₁✝ }> ∧ δ' ⊢ ρ'; constructor app₂.left δ:StoreTyt:Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρΓ:Contextτ₁✝:Tyτ₂✝:Tyt₁✝:Tmt₂✝:Tmh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₂✝ → τ₁✝ }>h₂:<{ ∅ / δ ⊢ t₂✝ ⦂ τ₂✝ }>ih₁:∀ {t' : Tm}, t₁✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₂✝ → τ₁✝ }> ∧ δ' ⊢ ρ'ih₂:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₂✝ }> ∧ δ' ⊢ ρ't₂'✝:Tmh₁✝:t₁✝.IsValuehs:t₂✝ / ρ ⟶ t₂'✝ / ρ'δ':StoreTyhExt:Extends δ' δhTy':<{ ∅ / δ' ⊢ t₂'✝ ⦂ τ₂✝ }>hStoreTy':δ' ⊢ ρ'⊢ Extends δ' δapp₂.right δ:StoreTyt:Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρΓ:Contextτ₁✝:Tyτ₂✝:Tyt₁✝:Tmt₂✝:Tmh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₂✝ → τ₁✝ }>h₂:<{ ∅ / δ ⊢ t₂✝ ⦂ τ₂✝ }>ih₁:∀ {t' : Tm}, t₁✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₂✝ → τ₁✝ }> ∧ δ' ⊢ ρ'ih₂:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₂✝ }> ∧ δ' ⊢ ρ't₂'✝:Tmh₁✝:t₁✝.IsValuehs:t₂✝ / ρ ⟶ t₂'✝ / ρ'δ':StoreTyhExt:Extends δ' δhTy':<{ ∅ / δ' ⊢ t₂'✝ ⦂ τ₂✝ }>hStoreTy':δ' ⊢ ρ'⊢ <{ ∅ / δ' ⊢ t₁✝ t₂'✝ ⦂ τ₁✝ }> ∧ δ' ⊢ ρ'
assumption app₂.right δ:StoreTyt:Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρΓ:Contextτ₁✝:Tyτ₂✝:Tyt₁✝:Tmt₂✝:Tmh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₂✝ → τ₁✝ }>h₂:<{ ∅ / δ ⊢ t₂✝ ⦂ τ₂✝ }>ih₁:∀ {t' : Tm}, t₁✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₂✝ → τ₁✝ }> ∧ δ' ⊢ ρ'ih₂:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₂✝ }> ∧ δ' ⊢ ρ't₂'✝:Tmh₁✝:t₁✝.IsValuehs:t₂✝ / ρ ⟶ t₂'✝ / ρ'δ':StoreTyhExt:Extends δ' δhTy':<{ ∅ / δ' ⊢ t₂'✝ ⦂ τ₂✝ }>hStoreTy':δ' ⊢ ρ'⊢ <{ ∅ / δ' ⊢ t₁✝ t₂'✝ ⦂ τ₁✝ }> ∧ δ' ⊢ ρ'; constructor app₂.right.left δ:StoreTyt:Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρΓ:Contextτ₁✝:Tyτ₂✝:Tyt₁✝:Tmt₂✝:Tmh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₂✝ → τ₁✝ }>h₂:<{ ∅ / δ ⊢ t₂✝ ⦂ τ₂✝ }>ih₁:∀ {t' : Tm}, t₁✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₂✝ → τ₁✝ }> ∧ δ' ⊢ ρ'ih₂:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₂✝ }> ∧ δ' ⊢ ρ't₂'✝:Tmh₁✝:t₁✝.IsValuehs:t₂✝ / ρ ⟶ t₂'✝ / ρ'δ':StoreTyhExt:Extends δ' δhTy':<{ ∅ / δ' ⊢ t₂'✝ ⦂ τ₂✝ }>hStoreTy':δ' ⊢ ρ'⊢ <{ ∅ / δ' ⊢ t₁✝ t₂'✝ ⦂ τ₁✝ }>app₂.right.right δ:StoreTyt:Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρΓ:Contextτ₁✝:Tyτ₂✝:Tyt₁✝:Tmt₂✝:Tmh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₂✝ → τ₁✝ }>h₂:<{ ∅ / δ ⊢ t₂✝ ⦂ τ₂✝ }>ih₁:∀ {t' : Tm}, t₁✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₂✝ → τ₁✝ }> ∧ δ' ⊢ ρ'ih₂:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₂✝ }> ∧ δ' ⊢ ρ't₂'✝:Tmh₁✝:t₁✝.IsValuehs:t₂✝ / ρ ⟶ t₂'✝ / ρ'δ':StoreTyhExt:Extends δ' δhTy':<{ ∅ / δ' ⊢ t₂'✝ ⦂ τ₂✝ }>hStoreTy':δ' ⊢ ρ'⊢ δ' ⊢ ρ'
solve_by_elim [store_weakening] using StlcRefTyping app₂.right.right δ:StoreTyt:Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρΓ:Contextτ₁✝:Tyτ₂✝:Tyt₁✝:Tmt₂✝:Tmh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₂✝ → τ₁✝ }>h₂:<{ ∅ / δ ⊢ t₂✝ ⦂ τ₂✝ }>ih₁:∀ {t' : Tm}, t₁✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₂✝ → τ₁✝ }> ∧ δ' ⊢ ρ'ih₂:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₂✝ }> ∧ δ' ⊢ ρ't₂'✝:Tmh₁✝:t₁✝.IsValuehs:t₂✝ / ρ ⟶ t₂'✝ / ρ'δ':StoreTyhExt:Extends δ' δhTy':<{ ∅ / δ' ⊢ t₂'✝ ⦂ τ₂✝ }>hStoreTy':δ' ⊢ ρ'⊢ δ' ⊢ ρ'
assumption All goals completed! 🐙
| succ _ ih => succ δ:StoreTyt:Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmt':TmhEval:<{ succ t₁✝ }> / ρ ⟶ t' / ρ'h✝:<{ ∅ / δ ⊢ t₁✝ ⦂ Nat }>ih:∀ {t' : Tm}, t₁✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ'⊢ ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ'
inversion hEval with
| succNat => succNat δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextn✝:Nath✝:<{ ∅ / δ ⊢ ~(Tm.const n✝) ⦂ Nat }>ih:∀ {t' : Tm}, Tm.const n✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ⊢ ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ ~(Tm.const (n✝ + 1)) ⦂ Nat }> ∧ δ' ⊢ ρ
exists δ succNat δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextn✝:Nath✝:<{ ∅ / δ ⊢ ~(Tm.const n✝) ⦂ Nat }>ih:∀ {t' : Tm}, Tm.const n✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ⊢ Extends δ δ ∧ <{ ∅ / δ ⊢ ~(Tm.const (n✝ + 1)) ⦂ Nat }> ∧ δ ⊢ ρ; constructor succNat.left δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextn✝:Nath✝:<{ ∅ / δ ⊢ ~(Tm.const n✝) ⦂ Nat }>ih:∀ {t' : Tm}, Tm.const n✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ⊢ Extends δ δsuccNat.right δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextn✝:Nath✝:<{ ∅ / δ ⊢ ~(Tm.const n✝) ⦂ Nat }>ih:∀ {t' : Tm}, Tm.const n✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ⊢ <{ ∅ / δ ⊢ ~(Tm.const (n✝ + 1)) ⦂ Nat }> ∧ δ ⊢ ρ
apply extends_refl succNat.right δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextn✝:Nath✝:<{ ∅ / δ ⊢ ~(Tm.const n✝) ⦂ Nat }>ih:∀ {t' : Tm}, Tm.const n✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ⊢ <{ ∅ / δ ⊢ ~(Tm.const (n✝ + 1)) ⦂ Nat }> ∧ δ ⊢ ρ; constructor succNat.right.left δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextn✝:Nath✝:<{ ∅ / δ ⊢ ~(Tm.const n✝) ⦂ Nat }>ih:∀ {t' : Tm}, Tm.const n✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ⊢ <{ ∅ / δ ⊢ ~(Tm.const (n✝ + 1)) ⦂ Nat }>succNat.right.right δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextn✝:Nath✝:<{ ∅ / δ ⊢ ~(Tm.const n✝) ⦂ Nat }>ih:∀ {t' : Tm}, Tm.const n✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ⊢ δ ⊢ ρ
constructor succNat.right.right δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextn✝:Nath✝:<{ ∅ / δ ⊢ ~(Tm.const n✝) ⦂ Nat }>ih:∀ {t' : Tm}, Tm.const n✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ⊢ δ ⊢ ρ
assumption All goals completed! 🐙
| succ hs => succ δ:StoreTyt:Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmh✝:<{ ∅ / δ ⊢ t₁✝ ⦂ Nat }>ih:∀ {t' : Tm}, t₁✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ't₁'✝:Tmhs:t₁✝ / ρ ⟶ t₁'✝ / ρ'⊢ ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ succ t₁'✝ ⦂ Nat }> ∧ δ' ⊢ ρ'
have ⟨δ', hExt, hTy', hStoreTy'⟩ := ih hs rfl succ δ:StoreTyt:Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmh✝:<{ ∅ / δ ⊢ t₁✝ ⦂ Nat }>ih:∀ {t' : Tm}, t₁✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ't₁'✝:Tmhs:t₁✝ / ρ ⟶ t₁'✝ / ρ'δ':StoreTyhExt:Extends δ' δhTy':<{ ∅ / δ' ⊢ t₁'✝ ⦂ Nat }>hStoreTy':δ' ⊢ ρ'⊢ ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ succ t₁'✝ ⦂ Nat }> ∧ δ' ⊢ ρ'
exists δ' succ δ:StoreTyt:Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmh✝:<{ ∅ / δ ⊢ t₁✝ ⦂ Nat }>ih:∀ {t' : Tm}, t₁✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ't₁'✝:Tmhs:t₁✝ / ρ ⟶ t₁'✝ / ρ'δ':StoreTyhExt:Extends δ' δhTy':<{ ∅ / δ' ⊢ t₁'✝ ⦂ Nat }>hStoreTy':δ' ⊢ ρ'⊢ Extends δ' δ ∧ <{ ∅ / δ' ⊢ succ t₁'✝ ⦂ Nat }> ∧ δ' ⊢ ρ'; constructor succ.left δ:StoreTyt:Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmh✝:<{ ∅ / δ ⊢ t₁✝ ⦂ Nat }>ih:∀ {t' : Tm}, t₁✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ't₁'✝:Tmhs:t₁✝ / ρ ⟶ t₁'✝ / ρ'δ':StoreTyhExt:Extends δ' δhTy':<{ ∅ / δ' ⊢ t₁'✝ ⦂ Nat }>hStoreTy':δ' ⊢ ρ'⊢ Extends δ' δsucc.right δ:StoreTyt:Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmh✝:<{ ∅ / δ ⊢ t₁✝ ⦂ Nat }>ih:∀ {t' : Tm}, t₁✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ't₁'✝:Tmhs:t₁✝ / ρ ⟶ t₁'✝ / ρ'δ':StoreTyhExt:Extends δ' δhTy':<{ ∅ / δ' ⊢ t₁'✝ ⦂ Nat }>hStoreTy':δ' ⊢ ρ'⊢ <{ ∅ / δ' ⊢ succ t₁'✝ ⦂ Nat }> ∧ δ' ⊢ ρ'
assumption succ.right δ:StoreTyt:Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmh✝:<{ ∅ / δ ⊢ t₁✝ ⦂ Nat }>ih:∀ {t' : Tm}, t₁✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ't₁'✝:Tmhs:t₁✝ / ρ ⟶ t₁'✝ / ρ'δ':StoreTyhExt:Extends δ' δhTy':<{ ∅ / δ' ⊢ t₁'✝ ⦂ Nat }>hStoreTy':δ' ⊢ ρ'⊢ <{ ∅ / δ' ⊢ succ t₁'✝ ⦂ Nat }> ∧ δ' ⊢ ρ'; constructor succ.right.left δ:StoreTyt:Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmh✝:<{ ∅ / δ ⊢ t₁✝ ⦂ Nat }>ih:∀ {t' : Tm}, t₁✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ't₁'✝:Tmhs:t₁✝ / ρ ⟶ t₁'✝ / ρ'δ':StoreTyhExt:Extends δ' δhTy':<{ ∅ / δ' ⊢ t₁'✝ ⦂ Nat }>hStoreTy':δ' ⊢ ρ'⊢ <{ ∅ / δ' ⊢ succ t₁'✝ ⦂ Nat }>succ.right.right δ:StoreTyt:Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmh✝:<{ ∅ / δ ⊢ t₁✝ ⦂ Nat }>ih:∀ {t' : Tm}, t₁✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ't₁'✝:Tmhs:t₁✝ / ρ ⟶ t₁'✝ / ρ'δ':StoreTyhExt:Extends δ' δhTy':<{ ∅ / δ' ⊢ t₁'✝ ⦂ Nat }>hStoreTy':δ' ⊢ ρ'⊢ δ' ⊢ ρ'
solve_by_elim [store_weakening] using StlcRefTyping succ.right.right δ:StoreTyt:Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmh✝:<{ ∅ / δ ⊢ t₁✝ ⦂ Nat }>ih:∀ {t' : Tm}, t₁✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ't₁'✝:Tmhs:t₁✝ / ρ ⟶ t₁'✝ / ρ'δ':StoreTyhExt:Extends δ' δhTy':<{ ∅ / δ' ⊢ t₁'✝ ⦂ Nat }>hStoreTy':δ' ⊢ ρ'⊢ δ' ⊢ ρ'
assumption All goals completed! 🐙
| pred _ ih => pred δ:StoreTyt:Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmt':TmhEval:<{ pred t₁✝ }> / ρ ⟶ t' / ρ'h✝:<{ ∅ / δ ⊢ t₁✝ ⦂ Nat }>ih:∀ {t' : Tm}, t₁✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ'⊢ ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ'
inversion hEval with
| predConst => predConst δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextn✝:Nath✝:<{ ∅ / δ ⊢ ~(Tm.const n✝) ⦂ Nat }>ih:∀ {t' : Tm}, Tm.const n✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ⊢ ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ ~(Tm.const (n✝ - 1)) ⦂ Nat }> ∧ δ' ⊢ ρ
exists δ predConst δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextn✝:Nath✝:<{ ∅ / δ ⊢ ~(Tm.const n✝) ⦂ Nat }>ih:∀ {t' : Tm}, Tm.const n✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ⊢ Extends δ δ ∧ <{ ∅ / δ ⊢ ~(Tm.const (n✝ - 1)) ⦂ Nat }> ∧ δ ⊢ ρ; constructor predConst.left δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextn✝:Nath✝:<{ ∅ / δ ⊢ ~(Tm.const n✝) ⦂ Nat }>ih:∀ {t' : Tm}, Tm.const n✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ⊢ Extends δ δpredConst.right δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextn✝:Nath✝:<{ ∅ / δ ⊢ ~(Tm.const n✝) ⦂ Nat }>ih:∀ {t' : Tm}, Tm.const n✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ⊢ <{ ∅ / δ ⊢ ~(Tm.const (n✝ - 1)) ⦂ Nat }> ∧ δ ⊢ ρ
apply extends_refl predConst.right δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextn✝:Nath✝:<{ ∅ / δ ⊢ ~(Tm.const n✝) ⦂ Nat }>ih:∀ {t' : Tm}, Tm.const n✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ⊢ <{ ∅ / δ ⊢ ~(Tm.const (n✝ - 1)) ⦂ Nat }> ∧ δ ⊢ ρ; constructor predConst.right.left δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextn✝:Nath✝:<{ ∅ / δ ⊢ ~(Tm.const n✝) ⦂ Nat }>ih:∀ {t' : Tm}, Tm.const n✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ⊢ <{ ∅ / δ ⊢ ~(Tm.const (n✝ - 1)) ⦂ Nat }>predConst.right.right δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextn✝:Nath✝:<{ ∅ / δ ⊢ ~(Tm.const n✝) ⦂ Nat }>ih:∀ {t' : Tm}, Tm.const n✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ⊢ δ ⊢ ρ
constructor predConst.right.right δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextn✝:Nath✝:<{ ∅ / δ ⊢ ~(Tm.const n✝) ⦂ Nat }>ih:∀ {t' : Tm}, Tm.const n✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ⊢ δ ⊢ ρ
assumption All goals completed! 🐙
| pred hs => pred δ:StoreTyt:Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmh✝:<{ ∅ / δ ⊢ t₁✝ ⦂ Nat }>ih:∀ {t' : Tm}, t₁✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ't₁'✝:Tmhs:t₁✝ / ρ ⟶ t₁'✝ / ρ'⊢ ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ pred t₁'✝ ⦂ Nat }> ∧ δ' ⊢ ρ'
have ⟨δ', hExt, hTy', hStoreTy'⟩ := ih hs rfl pred δ:StoreTyt:Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmh✝:<{ ∅ / δ ⊢ t₁✝ ⦂ Nat }>ih:∀ {t' : Tm}, t₁✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ't₁'✝:Tmhs:t₁✝ / ρ ⟶ t₁'✝ / ρ'δ':StoreTyhExt:Extends δ' δhTy':<{ ∅ / δ' ⊢ t₁'✝ ⦂ Nat }>hStoreTy':δ' ⊢ ρ'⊢ ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ pred t₁'✝ ⦂ Nat }> ∧ δ' ⊢ ρ'
exists δ' pred δ:StoreTyt:Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmh✝:<{ ∅ / δ ⊢ t₁✝ ⦂ Nat }>ih:∀ {t' : Tm}, t₁✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ't₁'✝:Tmhs:t₁✝ / ρ ⟶ t₁'✝ / ρ'δ':StoreTyhExt:Extends δ' δhTy':<{ ∅ / δ' ⊢ t₁'✝ ⦂ Nat }>hStoreTy':δ' ⊢ ρ'⊢ Extends δ' δ ∧ <{ ∅ / δ' ⊢ pred t₁'✝ ⦂ Nat }> ∧ δ' ⊢ ρ'; constructor pred.left δ:StoreTyt:Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmh✝:<{ ∅ / δ ⊢ t₁✝ ⦂ Nat }>ih:∀ {t' : Tm}, t₁✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ't₁'✝:Tmhs:t₁✝ / ρ ⟶ t₁'✝ / ρ'δ':StoreTyhExt:Extends δ' δhTy':<{ ∅ / δ' ⊢ t₁'✝ ⦂ Nat }>hStoreTy':δ' ⊢ ρ'⊢ Extends δ' δpred.right δ:StoreTyt:Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmh✝:<{ ∅ / δ ⊢ t₁✝ ⦂ Nat }>ih:∀ {t' : Tm}, t₁✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ't₁'✝:Tmhs:t₁✝ / ρ ⟶ t₁'✝ / ρ'δ':StoreTyhExt:Extends δ' δhTy':<{ ∅ / δ' ⊢ t₁'✝ ⦂ Nat }>hStoreTy':δ' ⊢ ρ'⊢ <{ ∅ / δ' ⊢ pred t₁'✝ ⦂ Nat }> ∧ δ' ⊢ ρ'
assumption pred.right δ:StoreTyt:Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmh✝:<{ ∅ / δ ⊢ t₁✝ ⦂ Nat }>ih:∀ {t' : Tm}, t₁✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ't₁'✝:Tmhs:t₁✝ / ρ ⟶ t₁'✝ / ρ'δ':StoreTyhExt:Extends δ' δhTy':<{ ∅ / δ' ⊢ t₁'✝ ⦂ Nat }>hStoreTy':δ' ⊢ ρ'⊢ <{ ∅ / δ' ⊢ pred t₁'✝ ⦂ Nat }> ∧ δ' ⊢ ρ'; constructor pred.right.left δ:StoreTyt:Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmh✝:<{ ∅ / δ ⊢ t₁✝ ⦂ Nat }>ih:∀ {t' : Tm}, t₁✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ't₁'✝:Tmhs:t₁✝ / ρ ⟶ t₁'✝ / ρ'δ':StoreTyhExt:Extends δ' δhTy':<{ ∅ / δ' ⊢ t₁'✝ ⦂ Nat }>hStoreTy':δ' ⊢ ρ'⊢ <{ ∅ / δ' ⊢ pred t₁'✝ ⦂ Nat }>pred.right.right δ:StoreTyt:Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmh✝:<{ ∅ / δ ⊢ t₁✝ ⦂ Nat }>ih:∀ {t' : Tm}, t₁✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ't₁'✝:Tmhs:t₁✝ / ρ ⟶ t₁'✝ / ρ'δ':StoreTyhExt:Extends δ' δhTy':<{ ∅ / δ' ⊢ t₁'✝ ⦂ Nat }>hStoreTy':δ' ⊢ ρ'⊢ δ' ⊢ ρ'
solve_by_elim [store_weakening] using StlcRefTyping pred.right.right δ:StoreTyt:Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmh✝:<{ ∅ / δ ⊢ t₁✝ ⦂ Nat }>ih:∀ {t' : Tm}, t₁✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ't₁'✝:Tmhs:t₁✝ / ρ ⟶ t₁'✝ / ρ'δ':StoreTyhExt:Extends δ' δhTy':<{ ∅ / δ' ⊢ t₁'✝ ⦂ Nat }>hStoreTy':δ' ⊢ ρ'⊢ δ' ⊢ ρ'
assumption All goals completed! 🐙
| mult h₁ h₂ ih₁ ih₂ => mult δ:StoreTyt:Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmt₂✝:Tmt':TmhEval:<{ t₁✝ * t₂✝ }> / ρ ⟶ t' / ρ'h₁:<{ ∅ / δ ⊢ t₁✝ ⦂ Nat }>h₂:<{ ∅ / δ ⊢ t₂✝ ⦂ Nat }>ih₁:∀ {t' : Tm}, t₁✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ'ih₂:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ'⊢ ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ'
inversion hEval with
| multConst => multConst δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextn₁✝:Natn₂✝:Nath₁:<{ ∅ / δ ⊢ ~(Tm.const n₁✝) ⦂ Nat }>h₂:<{ ∅ / δ ⊢ ~(Tm.const n₂✝) ⦂ Nat }>ih₁:∀ {t' : Tm}, Tm.const n₁✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρih₂:∀ {t' : Tm}, Tm.const n₂✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ⊢ ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ ~(Tm.const (n₁✝ * n₂✝)) ⦂ Nat }> ∧ δ' ⊢ ρ
exists δ multConst δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextn₁✝:Natn₂✝:Nath₁:<{ ∅ / δ ⊢ ~(Tm.const n₁✝) ⦂ Nat }>h₂:<{ ∅ / δ ⊢ ~(Tm.const n₂✝) ⦂ Nat }>ih₁:∀ {t' : Tm}, Tm.const n₁✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρih₂:∀ {t' : Tm}, Tm.const n₂✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ⊢ Extends δ δ ∧ <{ ∅ / δ ⊢ ~(Tm.const (n₁✝ * n₂✝)) ⦂ Nat }> ∧ δ ⊢ ρ; constructor multConst.left δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextn₁✝:Natn₂✝:Nath₁:<{ ∅ / δ ⊢ ~(Tm.const n₁✝) ⦂ Nat }>h₂:<{ ∅ / δ ⊢ ~(Tm.const n₂✝) ⦂ Nat }>ih₁:∀ {t' : Tm}, Tm.const n₁✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρih₂:∀ {t' : Tm}, Tm.const n₂✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ⊢ Extends δ δmultConst.right δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextn₁✝:Natn₂✝:Nath₁:<{ ∅ / δ ⊢ ~(Tm.const n₁✝) ⦂ Nat }>h₂:<{ ∅ / δ ⊢ ~(Tm.const n₂✝) ⦂ Nat }>ih₁:∀ {t' : Tm}, Tm.const n₁✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρih₂:∀ {t' : Tm}, Tm.const n₂✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ⊢ <{ ∅ / δ ⊢ ~(Tm.const (n₁✝ * n₂✝)) ⦂ Nat }> ∧ δ ⊢ ρ
apply extends_refl multConst.right δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextn₁✝:Natn₂✝:Nath₁:<{ ∅ / δ ⊢ ~(Tm.const n₁✝) ⦂ Nat }>h₂:<{ ∅ / δ ⊢ ~(Tm.const n₂✝) ⦂ Nat }>ih₁:∀ {t' : Tm}, Tm.const n₁✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρih₂:∀ {t' : Tm}, Tm.const n₂✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ⊢ <{ ∅ / δ ⊢ ~(Tm.const (n₁✝ * n₂✝)) ⦂ Nat }> ∧ δ ⊢ ρ; constructor multConst.right.left δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextn₁✝:Natn₂✝:Nath₁:<{ ∅ / δ ⊢ ~(Tm.const n₁✝) ⦂ Nat }>h₂:<{ ∅ / δ ⊢ ~(Tm.const n₂✝) ⦂ Nat }>ih₁:∀ {t' : Tm}, Tm.const n₁✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρih₂:∀ {t' : Tm}, Tm.const n₂✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ⊢ <{ ∅ / δ ⊢ ~(Tm.const (n₁✝ * n₂✝)) ⦂ Nat }>multConst.right.right δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextn₁✝:Natn₂✝:Nath₁:<{ ∅ / δ ⊢ ~(Tm.const n₁✝) ⦂ Nat }>h₂:<{ ∅ / δ ⊢ ~(Tm.const n₂✝) ⦂ Nat }>ih₁:∀ {t' : Tm}, Tm.const n₁✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρih₂:∀ {t' : Tm}, Tm.const n₂✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ⊢ δ ⊢ ρ
constructor multConst.right.right δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextn₁✝:Natn₂✝:Nath₁:<{ ∅ / δ ⊢ ~(Tm.const n₁✝) ⦂ Nat }>h₂:<{ ∅ / δ ⊢ ~(Tm.const n₂✝) ⦂ Nat }>ih₁:∀ {t' : Tm}, Tm.const n₁✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρih₂:∀ {t' : Tm}, Tm.const n₂✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ⊢ δ ⊢ ρ
assumption All goals completed! 🐙
| mult₁ hs => mult₁ δ:StoreTyt:Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmt₂✝:Tmh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ Nat }>h₂:<{ ∅ / δ ⊢ t₂✝ ⦂ Nat }>ih₁:∀ {t' : Tm}, t₁✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ'ih₂:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ't₁'✝:Tmhs:t₁✝ / ρ ⟶ t₁'✝ / ρ'⊢ ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t₁'✝ * t₂✝ ⦂ Nat }> ∧ δ' ⊢ ρ'
have ⟨δ', hExt, hTy', hStoreTy'⟩ := ih₁ hs rfl mult₁ δ:StoreTyt:Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmt₂✝:Tmh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ Nat }>h₂:<{ ∅ / δ ⊢ t₂✝ ⦂ Nat }>ih₁:∀ {t' : Tm}, t₁✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ'ih₂:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ't₁'✝:Tmhs:t₁✝ / ρ ⟶ t₁'✝ / ρ'δ':StoreTyhExt:Extends δ' δhTy':<{ ∅ / δ' ⊢ t₁'✝ ⦂ Nat }>hStoreTy':δ' ⊢ ρ'⊢ ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t₁'✝ * t₂✝ ⦂ Nat }> ∧ δ' ⊢ ρ'
exists δ' mult₁ δ:StoreTyt:Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmt₂✝:Tmh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ Nat }>h₂:<{ ∅ / δ ⊢ t₂✝ ⦂ Nat }>ih₁:∀ {t' : Tm}, t₁✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ'ih₂:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ't₁'✝:Tmhs:t₁✝ / ρ ⟶ t₁'✝ / ρ'δ':StoreTyhExt:Extends δ' δhTy':<{ ∅ / δ' ⊢ t₁'✝ ⦂ Nat }>hStoreTy':δ' ⊢ ρ'⊢ Extends δ' δ ∧ <{ ∅ / δ' ⊢ t₁'✝ * t₂✝ ⦂ Nat }> ∧ δ' ⊢ ρ'; constructor mult₁.left δ:StoreTyt:Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmt₂✝:Tmh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ Nat }>h₂:<{ ∅ / δ ⊢ t₂✝ ⦂ Nat }>ih₁:∀ {t' : Tm}, t₁✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ'ih₂:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ't₁'✝:Tmhs:t₁✝ / ρ ⟶ t₁'✝ / ρ'δ':StoreTyhExt:Extends δ' δhTy':<{ ∅ / δ' ⊢ t₁'✝ ⦂ Nat }>hStoreTy':δ' ⊢ ρ'⊢ Extends δ' δmult₁.right δ:StoreTyt:Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmt₂✝:Tmh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ Nat }>h₂:<{ ∅ / δ ⊢ t₂✝ ⦂ Nat }>ih₁:∀ {t' : Tm}, t₁✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ'ih₂:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ't₁'✝:Tmhs:t₁✝ / ρ ⟶ t₁'✝ / ρ'δ':StoreTyhExt:Extends δ' δhTy':<{ ∅ / δ' ⊢ t₁'✝ ⦂ Nat }>hStoreTy':δ' ⊢ ρ'⊢ <{ ∅ / δ' ⊢ t₁'✝ * t₂✝ ⦂ Nat }> ∧ δ' ⊢ ρ'
assumption mult₁.right δ:StoreTyt:Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmt₂✝:Tmh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ Nat }>h₂:<{ ∅ / δ ⊢ t₂✝ ⦂ Nat }>ih₁:∀ {t' : Tm}, t₁✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ'ih₂:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ't₁'✝:Tmhs:t₁✝ / ρ ⟶ t₁'✝ / ρ'δ':StoreTyhExt:Extends δ' δhTy':<{ ∅ / δ' ⊢ t₁'✝ ⦂ Nat }>hStoreTy':δ' ⊢ ρ'⊢ <{ ∅ / δ' ⊢ t₁'✝ * t₂✝ ⦂ Nat }> ∧ δ' ⊢ ρ'; constructor mult₁.right.left δ:StoreTyt:Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmt₂✝:Tmh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ Nat }>h₂:<{ ∅ / δ ⊢ t₂✝ ⦂ Nat }>ih₁:∀ {t' : Tm}, t₁✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ'ih₂:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ't₁'✝:Tmhs:t₁✝ / ρ ⟶ t₁'✝ / ρ'δ':StoreTyhExt:Extends δ' δhTy':<{ ∅ / δ' ⊢ t₁'✝ ⦂ Nat }>hStoreTy':δ' ⊢ ρ'⊢ <{ ∅ / δ' ⊢ t₁'✝ * t₂✝ ⦂ Nat }>mult₁.right.right δ:StoreTyt:Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmt₂✝:Tmh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ Nat }>h₂:<{ ∅ / δ ⊢ t₂✝ ⦂ Nat }>ih₁:∀ {t' : Tm}, t₁✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ'ih₂:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ't₁'✝:Tmhs:t₁✝ / ρ ⟶ t₁'✝ / ρ'δ':StoreTyhExt:Extends δ' δhTy':<{ ∅ / δ' ⊢ t₁'✝ ⦂ Nat }>hStoreTy':δ' ⊢ ρ'⊢ δ' ⊢ ρ'
solve_by_elim [store_weakening] using StlcRefTyping mult₁.right.right δ:StoreTyt:Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmt₂✝:Tmh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ Nat }>h₂:<{ ∅ / δ ⊢ t₂✝ ⦂ Nat }>ih₁:∀ {t' : Tm}, t₁✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ'ih₂:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ't₁'✝:Tmhs:t₁✝ / ρ ⟶ t₁'✝ / ρ'δ':StoreTyhExt:Extends δ' δhTy':<{ ∅ / δ' ⊢ t₁'✝ ⦂ Nat }>hStoreTy':δ' ⊢ ρ'⊢ δ' ⊢ ρ'
assumption All goals completed! 🐙
| mult₂ _ hs => mult₂ δ:StoreTyt:Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmt₂✝:Tmh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ Nat }>h₂:<{ ∅ / δ ⊢ t₂✝ ⦂ Nat }>ih₁:∀ {t' : Tm}, t₁✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ'ih₂:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ't₂'✝:Tmh₁✝:t₁✝.IsValuehs:t₂✝ / ρ ⟶ t₂'✝ / ρ'⊢ ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t₁✝ * t₂'✝ ⦂ Nat }> ∧ δ' ⊢ ρ'
have ⟨δ', hExt, hTy', hStoreTy'⟩ := ih₂ hs rfl mult₂ δ:StoreTyt:Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmt₂✝:Tmh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ Nat }>h₂:<{ ∅ / δ ⊢ t₂✝ ⦂ Nat }>ih₁:∀ {t' : Tm}, t₁✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ'ih₂:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ't₂'✝:Tmh₁✝:t₁✝.IsValuehs:t₂✝ / ρ ⟶ t₂'✝ / ρ'δ':StoreTyhExt:Extends δ' δhTy':<{ ∅ / δ' ⊢ t₂'✝ ⦂ Nat }>hStoreTy':δ' ⊢ ρ'⊢ ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t₁✝ * t₂'✝ ⦂ Nat }> ∧ δ' ⊢ ρ'
exists δ' mult₂ δ:StoreTyt:Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmt₂✝:Tmh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ Nat }>h₂:<{ ∅ / δ ⊢ t₂✝ ⦂ Nat }>ih₁:∀ {t' : Tm}, t₁✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ'ih₂:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ't₂'✝:Tmh₁✝:t₁✝.IsValuehs:t₂✝ / ρ ⟶ t₂'✝ / ρ'δ':StoreTyhExt:Extends δ' δhTy':<{ ∅ / δ' ⊢ t₂'✝ ⦂ Nat }>hStoreTy':δ' ⊢ ρ'⊢ Extends δ' δ ∧ <{ ∅ / δ' ⊢ t₁✝ * t₂'✝ ⦂ Nat }> ∧ δ' ⊢ ρ'; constructor mult₂.left δ:StoreTyt:Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmt₂✝:Tmh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ Nat }>h₂:<{ ∅ / δ ⊢ t₂✝ ⦂ Nat }>ih₁:∀ {t' : Tm}, t₁✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ'ih₂:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ't₂'✝:Tmh₁✝:t₁✝.IsValuehs:t₂✝ / ρ ⟶ t₂'✝ / ρ'δ':StoreTyhExt:Extends δ' δhTy':<{ ∅ / δ' ⊢ t₂'✝ ⦂ Nat }>hStoreTy':δ' ⊢ ρ'⊢ Extends δ' δmult₂.right δ:StoreTyt:Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmt₂✝:Tmh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ Nat }>h₂:<{ ∅ / δ ⊢ t₂✝ ⦂ Nat }>ih₁:∀ {t' : Tm}, t₁✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ'ih₂:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ't₂'✝:Tmh₁✝:t₁✝.IsValuehs:t₂✝ / ρ ⟶ t₂'✝ / ρ'δ':StoreTyhExt:Extends δ' δhTy':<{ ∅ / δ' ⊢ t₂'✝ ⦂ Nat }>hStoreTy':δ' ⊢ ρ'⊢ <{ ∅ / δ' ⊢ t₁✝ * t₂'✝ ⦂ Nat }> ∧ δ' ⊢ ρ'
assumption mult₂.right δ:StoreTyt:Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmt₂✝:Tmh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ Nat }>h₂:<{ ∅ / δ ⊢ t₂✝ ⦂ Nat }>ih₁:∀ {t' : Tm}, t₁✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ'ih₂:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ't₂'✝:Tmh₁✝:t₁✝.IsValuehs:t₂✝ / ρ ⟶ t₂'✝ / ρ'δ':StoreTyhExt:Extends δ' δhTy':<{ ∅ / δ' ⊢ t₂'✝ ⦂ Nat }>hStoreTy':δ' ⊢ ρ'⊢ <{ ∅ / δ' ⊢ t₁✝ * t₂'✝ ⦂ Nat }> ∧ δ' ⊢ ρ'; constructor mult₂.right.left δ:StoreTyt:Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmt₂✝:Tmh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ Nat }>h₂:<{ ∅ / δ ⊢ t₂✝ ⦂ Nat }>ih₁:∀ {t' : Tm}, t₁✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ'ih₂:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ't₂'✝:Tmh₁✝:t₁✝.IsValuehs:t₂✝ / ρ ⟶ t₂'✝ / ρ'δ':StoreTyhExt:Extends δ' δhTy':<{ ∅ / δ' ⊢ t₂'✝ ⦂ Nat }>hStoreTy':δ' ⊢ ρ'⊢ <{ ∅ / δ' ⊢ t₁✝ * t₂'✝ ⦂ Nat }>mult₂.right.right δ:StoreTyt:Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmt₂✝:Tmh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ Nat }>h₂:<{ ∅ / δ ⊢ t₂✝ ⦂ Nat }>ih₁:∀ {t' : Tm}, t₁✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ'ih₂:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ't₂'✝:Tmh₁✝:t₁✝.IsValuehs:t₂✝ / ρ ⟶ t₂'✝ / ρ'δ':StoreTyhExt:Extends δ' δhTy':<{ ∅ / δ' ⊢ t₂'✝ ⦂ Nat }>hStoreTy':δ' ⊢ ρ'⊢ δ' ⊢ ρ'
solve_by_elim [store_weakening] using StlcRefTyping mult₂.right.right δ:StoreTyt:Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmt₂✝:Tmh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ Nat }>h₂:<{ ∅ / δ ⊢ t₂✝ ⦂ Nat }>ih₁:∀ {t' : Tm}, t₁✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ'ih₂:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ't₂'✝:Tmh₁✝:t₁✝.IsValuehs:t₂✝ / ρ ⟶ t₂'✝ / ρ'δ':StoreTyhExt:Extends δ' δhTy':<{ ∅ / δ' ⊢ t₂'✝ ⦂ Nat }>hStoreTy':δ' ⊢ ρ'⊢ δ' ⊢ ρ'
assumption All goals completed! 🐙
| ite0 _ h₂ h₃ ih₁ _ _ => ite0 δ:StoreTyt:Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmt₂✝:Tmt₃✝:Tmτ✝:Tyt':TmhEval:<{ if0 t₁✝ then t₂✝ else t₃✝ }> / ρ ⟶ t' / ρ'h₁✝:<{ ∅ / δ ⊢ t₁✝ ⦂ Nat }>h₂:<{ ∅ / δ ⊢ t₂✝ ⦂ τ✝ }>h₃:<{ ∅ / δ ⊢ t₃✝ ⦂ τ✝ }>ih₁:∀ {t' : Tm}, t₁✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ'h₂_ih✝:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ✝ }> ∧ δ' ⊢ ρ'h₃_ih✝:∀ {t' : Tm}, t₃✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ✝ }> ∧ δ' ⊢ ρ'⊢ ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ✝ }> ∧ δ' ⊢ ρ'
inversion hEval with
| if0Step hs => if0Step δ:StoreTyt:Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmt₂✝:Tmt₃✝:Tmτ✝:Tyh₁✝:<{ ∅ / δ ⊢ t₁✝ ⦂ Nat }>h₂:<{ ∅ / δ ⊢ t₂✝ ⦂ τ✝ }>h₃:<{ ∅ / δ ⊢ t₃✝ ⦂ τ✝ }>ih₁:∀ {t' : Tm}, t₁✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ'h₂_ih✝:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ✝ }> ∧ δ' ⊢ ρ'h₃_ih✝:∀ {t' : Tm}, t₃✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ✝ }> ∧ δ' ⊢ ρ't₁'✝:Tmhs:t₁✝ / ρ ⟶ t₁'✝ / ρ'⊢ ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ if0 t₁'✝ then t₂✝ else t₃✝ ⦂ τ✝ }> ∧ δ' ⊢ ρ'
have ⟨δ', hExt, hTy', hStoreTy'⟩ := ih₁ hs rfl if0Step δ:StoreTyt:Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmt₂✝:Tmt₃✝:Tmτ✝:Tyh₁✝:<{ ∅ / δ ⊢ t₁✝ ⦂ Nat }>h₂:<{ ∅ / δ ⊢ t₂✝ ⦂ τ✝ }>h₃:<{ ∅ / δ ⊢ t₃✝ ⦂ τ✝ }>ih₁:∀ {t' : Tm}, t₁✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ'h₂_ih✝:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ✝ }> ∧ δ' ⊢ ρ'h₃_ih✝:∀ {t' : Tm}, t₃✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ✝ }> ∧ δ' ⊢ ρ't₁'✝:Tmhs:t₁✝ / ρ ⟶ t₁'✝ / ρ'δ':StoreTyhExt:Extends δ' δhTy':<{ ∅ / δ' ⊢ t₁'✝ ⦂ Nat }>hStoreTy':δ' ⊢ ρ'⊢ ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ if0 t₁'✝ then t₂✝ else t₃✝ ⦂ τ✝ }> ∧ δ' ⊢ ρ'
exists δ' if0Step δ:StoreTyt:Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmt₂✝:Tmt₃✝:Tmτ✝:Tyh₁✝:<{ ∅ / δ ⊢ t₁✝ ⦂ Nat }>h₂:<{ ∅ / δ ⊢ t₂✝ ⦂ τ✝ }>h₃:<{ ∅ / δ ⊢ t₃✝ ⦂ τ✝ }>ih₁:∀ {t' : Tm}, t₁✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ'h₂_ih✝:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ✝ }> ∧ δ' ⊢ ρ'h₃_ih✝:∀ {t' : Tm}, t₃✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ✝ }> ∧ δ' ⊢ ρ't₁'✝:Tmhs:t₁✝ / ρ ⟶ t₁'✝ / ρ'δ':StoreTyhExt:Extends δ' δhTy':<{ ∅ / δ' ⊢ t₁'✝ ⦂ Nat }>hStoreTy':δ' ⊢ ρ'⊢ Extends δ' δ ∧ <{ ∅ / δ' ⊢ if0 t₁'✝ then t₂✝ else t₃✝ ⦂ τ✝ }> ∧ δ' ⊢ ρ'; constructor if0Step.left δ:StoreTyt:Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmt₂✝:Tmt₃✝:Tmτ✝:Tyh₁✝:<{ ∅ / δ ⊢ t₁✝ ⦂ Nat }>h₂:<{ ∅ / δ ⊢ t₂✝ ⦂ τ✝ }>h₃:<{ ∅ / δ ⊢ t₃✝ ⦂ τ✝ }>ih₁:∀ {t' : Tm}, t₁✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ'h₂_ih✝:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ✝ }> ∧ δ' ⊢ ρ'h₃_ih✝:∀ {t' : Tm}, t₃✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ✝ }> ∧ δ' ⊢ ρ't₁'✝:Tmhs:t₁✝ / ρ ⟶ t₁'✝ / ρ'δ':StoreTyhExt:Extends δ' δhTy':<{ ∅ / δ' ⊢ t₁'✝ ⦂ Nat }>hStoreTy':δ' ⊢ ρ'⊢ Extends δ' δif0Step.right δ:StoreTyt:Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmt₂✝:Tmt₃✝:Tmτ✝:Tyh₁✝:<{ ∅ / δ ⊢ t₁✝ ⦂ Nat }>h₂:<{ ∅ / δ ⊢ t₂✝ ⦂ τ✝ }>h₃:<{ ∅ / δ ⊢ t₃✝ ⦂ τ✝ }>ih₁:∀ {t' : Tm}, t₁✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ'h₂_ih✝:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ✝ }> ∧ δ' ⊢ ρ'h₃_ih✝:∀ {t' : Tm}, t₃✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ✝ }> ∧ δ' ⊢ ρ't₁'✝:Tmhs:t₁✝ / ρ ⟶ t₁'✝ / ρ'δ':StoreTyhExt:Extends δ' δhTy':<{ ∅ / δ' ⊢ t₁'✝ ⦂ Nat }>hStoreTy':δ' ⊢ ρ'⊢ <{ ∅ / δ' ⊢ if0 t₁'✝ then t₂✝ else t₃✝ ⦂ τ✝ }> ∧ δ' ⊢ ρ'
assumption if0Step.right δ:StoreTyt:Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmt₂✝:Tmt₃✝:Tmτ✝:Tyh₁✝:<{ ∅ / δ ⊢ t₁✝ ⦂ Nat }>h₂:<{ ∅ / δ ⊢ t₂✝ ⦂ τ✝ }>h₃:<{ ∅ / δ ⊢ t₃✝ ⦂ τ✝ }>ih₁:∀ {t' : Tm}, t₁✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ'h₂_ih✝:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ✝ }> ∧ δ' ⊢ ρ'h₃_ih✝:∀ {t' : Tm}, t₃✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ✝ }> ∧ δ' ⊢ ρ't₁'✝:Tmhs:t₁✝ / ρ ⟶ t₁'✝ / ρ'δ':StoreTyhExt:Extends δ' δhTy':<{ ∅ / δ' ⊢ t₁'✝ ⦂ Nat }>hStoreTy':δ' ⊢ ρ'⊢ <{ ∅ / δ' ⊢ if0 t₁'✝ then t₂✝ else t₃✝ ⦂ τ✝ }> ∧ δ' ⊢ ρ'; constructor if0Step.right.left δ:StoreTyt:Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmt₂✝:Tmt₃✝:Tmτ✝:Tyh₁✝:<{ ∅ / δ ⊢ t₁✝ ⦂ Nat }>h₂:<{ ∅ / δ ⊢ t₂✝ ⦂ τ✝ }>h₃:<{ ∅ / δ ⊢ t₃✝ ⦂ τ✝ }>ih₁:∀ {t' : Tm}, t₁✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ'h₂_ih✝:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ✝ }> ∧ δ' ⊢ ρ'h₃_ih✝:∀ {t' : Tm}, t₃✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ✝ }> ∧ δ' ⊢ ρ't₁'✝:Tmhs:t₁✝ / ρ ⟶ t₁'✝ / ρ'δ':StoreTyhExt:Extends δ' δhTy':<{ ∅ / δ' ⊢ t₁'✝ ⦂ Nat }>hStoreTy':δ' ⊢ ρ'⊢ <{ ∅ / δ' ⊢ if0 t₁'✝ then t₂✝ else t₃✝ ⦂ τ✝ }>if0Step.right.right δ:StoreTyt:Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmt₂✝:Tmt₃✝:Tmτ✝:Tyh₁✝:<{ ∅ / δ ⊢ t₁✝ ⦂ Nat }>h₂:<{ ∅ / δ ⊢ t₂✝ ⦂ τ✝ }>h₃:<{ ∅ / δ ⊢ t₃✝ ⦂ τ✝ }>ih₁:∀ {t' : Tm}, t₁✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ'h₂_ih✝:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ✝ }> ∧ δ' ⊢ ρ'h₃_ih✝:∀ {t' : Tm}, t₃✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ✝ }> ∧ δ' ⊢ ρ't₁'✝:Tmhs:t₁✝ / ρ ⟶ t₁'✝ / ρ'δ':StoreTyhExt:Extends δ' δhTy':<{ ∅ / δ' ⊢ t₁'✝ ⦂ Nat }>hStoreTy':δ' ⊢ ρ'⊢ δ' ⊢ ρ'
constructor if0Step.right.left.h₁ δ:StoreTyt:Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmt₂✝:Tmt₃✝:Tmτ✝:Tyh₁✝:<{ ∅ / δ ⊢ t₁✝ ⦂ Nat }>h₂:<{ ∅ / δ ⊢ t₂✝ ⦂ τ✝ }>h₃:<{ ∅ / δ ⊢ t₃✝ ⦂ τ✝ }>ih₁:∀ {t' : Tm}, t₁✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ'h₂_ih✝:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ✝ }> ∧ δ' ⊢ ρ'h₃_ih✝:∀ {t' : Tm}, t₃✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ✝ }> ∧ δ' ⊢ ρ't₁'✝:Tmhs:t₁✝ / ρ ⟶ t₁'✝ / ρ'δ':StoreTyhExt:Extends δ' δhTy':<{ ∅ / δ' ⊢ t₁'✝ ⦂ Nat }>hStoreTy':δ' ⊢ ρ'⊢ <{ ∅ / δ' ⊢ t₁'✝ ⦂ Nat }>if0Step.right.left.h₂ δ:StoreTyt:Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmt₂✝:Tmt₃✝:Tmτ✝:Tyh₁✝:<{ ∅ / δ ⊢ t₁✝ ⦂ Nat }>h₂:<{ ∅ / δ ⊢ t₂✝ ⦂ τ✝ }>h₃:<{ ∅ / δ ⊢ t₃✝ ⦂ τ✝ }>ih₁:∀ {t' : Tm}, t₁✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ'h₂_ih✝:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ✝ }> ∧ δ' ⊢ ρ'h₃_ih✝:∀ {t' : Tm}, t₃✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ✝ }> ∧ δ' ⊢ ρ't₁'✝:Tmhs:t₁✝ / ρ ⟶ t₁'✝ / ρ'δ':StoreTyhExt:Extends δ' δhTy':<{ ∅ / δ' ⊢ t₁'✝ ⦂ Nat }>hStoreTy':δ' ⊢ ρ'⊢ <{ ∅ / δ' ⊢ t₂✝ ⦂ τ✝ }>if0Step.right.left.h₃ δ:StoreTyt:Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmt₂✝:Tmt₃✝:Tmτ✝:Tyh₁✝:<{ ∅ / δ ⊢ t₁✝ ⦂ Nat }>h₂:<{ ∅ / δ ⊢ t₂✝ ⦂ τ✝ }>h₃:<{ ∅ / δ ⊢ t₃✝ ⦂ τ✝ }>ih₁:∀ {t' : Tm}, t₁✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ'h₂_ih✝:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ✝ }> ∧ δ' ⊢ ρ'h₃_ih✝:∀ {t' : Tm}, t₃✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ✝ }> ∧ δ' ⊢ ρ't₁'✝:Tmhs:t₁✝ / ρ ⟶ t₁'✝ / ρ'δ':StoreTyhExt:Extends δ' δhTy':<{ ∅ / δ' ⊢ t₁'✝ ⦂ Nat }>hStoreTy':δ' ⊢ ρ'⊢ <{ ∅ / δ' ⊢ t₃✝ ⦂ τ✝ }> <;> if0Step.right.left.h₁ δ:StoreTyt:Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmt₂✝:Tmt₃✝:Tmτ✝:Tyh₁✝:<{ ∅ / δ ⊢ t₁✝ ⦂ Nat }>h₂:<{ ∅ / δ ⊢ t₂✝ ⦂ τ✝ }>h₃:<{ ∅ / δ ⊢ t₃✝ ⦂ τ✝ }>ih₁:∀ {t' : Tm}, t₁✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ'h₂_ih✝:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ✝ }> ∧ δ' ⊢ ρ'h₃_ih✝:∀ {t' : Tm}, t₃✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ✝ }> ∧ δ' ⊢ ρ't₁'✝:Tmhs:t₁✝ / ρ ⟶ t₁'✝ / ρ'δ':StoreTyhExt:Extends δ' δhTy':<{ ∅ / δ' ⊢ t₁'✝ ⦂ Nat }>hStoreTy':δ' ⊢ ρ'⊢ <{ ∅ / δ' ⊢ t₁'✝ ⦂ Nat }>if0Step.right.left.h₂ δ:StoreTyt:Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmt₂✝:Tmt₃✝:Tmτ✝:Tyh₁✝:<{ ∅ / δ ⊢ t₁✝ ⦂ Nat }>h₂:<{ ∅ / δ ⊢ t₂✝ ⦂ τ✝ }>h₃:<{ ∅ / δ ⊢ t₃✝ ⦂ τ✝ }>ih₁:∀ {t' : Tm}, t₁✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ'h₂_ih✝:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ✝ }> ∧ δ' ⊢ ρ'h₃_ih✝:∀ {t' : Tm}, t₃✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ✝ }> ∧ δ' ⊢ ρ't₁'✝:Tmhs:t₁✝ / ρ ⟶ t₁'✝ / ρ'δ':StoreTyhExt:Extends δ' δhTy':<{ ∅ / δ' ⊢ t₁'✝ ⦂ Nat }>hStoreTy':δ' ⊢ ρ'⊢ <{ ∅ / δ' ⊢ t₂✝ ⦂ τ✝ }>if0Step.right.left.h₃ δ:StoreTyt:Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmt₂✝:Tmt₃✝:Tmτ✝:Tyh₁✝:<{ ∅ / δ ⊢ t₁✝ ⦂ Nat }>h₂:<{ ∅ / δ ⊢ t₂✝ ⦂ τ✝ }>h₃:<{ ∅ / δ ⊢ t₃✝ ⦂ τ✝ }>ih₁:∀ {t' : Tm}, t₁✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ'h₂_ih✝:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ✝ }> ∧ δ' ⊢ ρ'h₃_ih✝:∀ {t' : Tm}, t₃✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ✝ }> ∧ δ' ⊢ ρ't₁'✝:Tmhs:t₁✝ / ρ ⟶ t₁'✝ / ρ'δ':StoreTyhExt:Extends δ' δhTy':<{ ∅ / δ' ⊢ t₁'✝ ⦂ Nat }>hStoreTy':δ' ⊢ ρ'⊢ <{ ∅ / δ' ⊢ t₃✝ ⦂ τ✝ }> solve_by_elim [store_weakening] using StlcRefTyping All goals completed! 🐙
assumption All goals completed! 🐙
| if0Zero => if0Zero δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextt₂✝:Tmt₃✝:Tmτ✝:Tyh₂:<{ ∅ / δ ⊢ t₂✝ ⦂ τ✝ }>h₃:<{ ∅ / δ ⊢ t₃✝ ⦂ τ✝ }>h₁✝:<{ ∅ / δ ⊢ 0 ⦂ Nat }>h₂_ih✝:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ✝ }> ∧ δ' ⊢ ρh₃_ih✝:∀ {t' : Tm}, t₃✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ✝ }> ∧ δ' ⊢ ρih₁:∀ {t' : Tm}, <{ 0 }> / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ⊢ ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t₂✝ ⦂ τ✝ }> ∧ δ' ⊢ ρ
exists δ if0Zero δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextt₂✝:Tmt₃✝:Tmτ✝:Tyh₂:<{ ∅ / δ ⊢ t₂✝ ⦂ τ✝ }>h₃:<{ ∅ / δ ⊢ t₃✝ ⦂ τ✝ }>h₁✝:<{ ∅ / δ ⊢ 0 ⦂ Nat }>h₂_ih✝:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ✝ }> ∧ δ' ⊢ ρh₃_ih✝:∀ {t' : Tm}, t₃✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ✝ }> ∧ δ' ⊢ ρih₁:∀ {t' : Tm}, <{ 0 }> / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ⊢ Extends δ δ ∧ <{ ∅ / δ ⊢ t₂✝ ⦂ τ✝ }> ∧ δ ⊢ ρ; constructor if0Zero.left δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextt₂✝:Tmt₃✝:Tmτ✝:Tyh₂:<{ ∅ / δ ⊢ t₂✝ ⦂ τ✝ }>h₃:<{ ∅ / δ ⊢ t₃✝ ⦂ τ✝ }>h₁✝:<{ ∅ / δ ⊢ 0 ⦂ Nat }>h₂_ih✝:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ✝ }> ∧ δ' ⊢ ρh₃_ih✝:∀ {t' : Tm}, t₃✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ✝ }> ∧ δ' ⊢ ρih₁:∀ {t' : Tm}, <{ 0 }> / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ⊢ Extends δ δif0Zero.right δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextt₂✝:Tmt₃✝:Tmτ✝:Tyh₂:<{ ∅ / δ ⊢ t₂✝ ⦂ τ✝ }>h₃:<{ ∅ / δ ⊢ t₃✝ ⦂ τ✝ }>h₁✝:<{ ∅ / δ ⊢ 0 ⦂ Nat }>h₂_ih✝:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ✝ }> ∧ δ' ⊢ ρh₃_ih✝:∀ {t' : Tm}, t₃✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ✝ }> ∧ δ' ⊢ ρih₁:∀ {t' : Tm}, <{ 0 }> / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ⊢ <{ ∅ / δ ⊢ t₂✝ ⦂ τ✝ }> ∧ δ ⊢ ρ
apply extends_refl if0Zero.right δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextt₂✝:Tmt₃✝:Tmτ✝:Tyh₂:<{ ∅ / δ ⊢ t₂✝ ⦂ τ✝ }>h₃:<{ ∅ / δ ⊢ t₃✝ ⦂ τ✝ }>h₁✝:<{ ∅ / δ ⊢ 0 ⦂ Nat }>h₂_ih✝:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ✝ }> ∧ δ' ⊢ ρh₃_ih✝:∀ {t' : Tm}, t₃✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ✝ }> ∧ δ' ⊢ ρih₁:∀ {t' : Tm}, <{ 0 }> / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ⊢ <{ ∅ / δ ⊢ t₂✝ ⦂ τ✝ }> ∧ δ ⊢ ρ; constructor if0Zero.right.left δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextt₂✝:Tmt₃✝:Tmτ✝:Tyh₂:<{ ∅ / δ ⊢ t₂✝ ⦂ τ✝ }>h₃:<{ ∅ / δ ⊢ t₃✝ ⦂ τ✝ }>h₁✝:<{ ∅ / δ ⊢ 0 ⦂ Nat }>h₂_ih✝:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ✝ }> ∧ δ' ⊢ ρh₃_ih✝:∀ {t' : Tm}, t₃✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ✝ }> ∧ δ' ⊢ ρih₁:∀ {t' : Tm}, <{ 0 }> / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ⊢ <{ ∅ / δ ⊢ t₂✝ ⦂ τ✝ }>if0Zero.right.right δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextt₂✝:Tmt₃✝:Tmτ✝:Tyh₂:<{ ∅ / δ ⊢ t₂✝ ⦂ τ✝ }>h₃:<{ ∅ / δ ⊢ t₃✝ ⦂ τ✝ }>h₁✝:<{ ∅ / δ ⊢ 0 ⦂ Nat }>h₂_ih✝:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ✝ }> ∧ δ' ⊢ ρh₃_ih✝:∀ {t' : Tm}, t₃✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ✝ }> ∧ δ' ⊢ ρih₁:∀ {t' : Tm}, <{ 0 }> / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ⊢ δ ⊢ ρ <;> if0Zero.right.left δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextt₂✝:Tmt₃✝:Tmτ✝:Tyh₂:<{ ∅ / δ ⊢ t₂✝ ⦂ τ✝ }>h₃:<{ ∅ / δ ⊢ t₃✝ ⦂ τ✝ }>h₁✝:<{ ∅ / δ ⊢ 0 ⦂ Nat }>h₂_ih✝:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ✝ }> ∧ δ' ⊢ ρh₃_ih✝:∀ {t' : Tm}, t₃✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ✝ }> ∧ δ' ⊢ ρih₁:∀ {t' : Tm}, <{ 0 }> / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ⊢ <{ ∅ / δ ⊢ t₂✝ ⦂ τ✝ }>if0Zero.right.right δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextt₂✝:Tmt₃✝:Tmτ✝:Tyh₂:<{ ∅ / δ ⊢ t₂✝ ⦂ τ✝ }>h₃:<{ ∅ / δ ⊢ t₃✝ ⦂ τ✝ }>h₁✝:<{ ∅ / δ ⊢ 0 ⦂ Nat }>h₂_ih✝:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ✝ }> ∧ δ' ⊢ ρh₃_ih✝:∀ {t' : Tm}, t₃✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ✝ }> ∧ δ' ⊢ ρih₁:∀ {t' : Tm}, <{ 0 }> / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ⊢ δ ⊢ ρ assumption All goals completed! 🐙
| if0Nonzero => if0Nonzero δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextt₂✝:Tmt₃✝:Tmτ✝:Tyh₂:<{ ∅ / δ ⊢ t₂✝ ⦂ τ✝ }>h₃:<{ ∅ / δ ⊢ t₃✝ ⦂ τ✝ }>n✝:Nath₁✝:<{ ∅ / δ ⊢ ~(Tm.const (n✝ + 1)) ⦂ Nat }>h₂_ih✝:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ✝ }> ∧ δ' ⊢ ρh₃_ih✝:∀ {t' : Tm}, t₃✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ✝ }> ∧ δ' ⊢ ρih₁:∀ {t' : Tm}, Tm.const (n✝ + 1) / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ⊢ ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t₃✝ ⦂ τ✝ }> ∧ δ' ⊢ ρ
exists δ if0Nonzero δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextt₂✝:Tmt₃✝:Tmτ✝:Tyh₂:<{ ∅ / δ ⊢ t₂✝ ⦂ τ✝ }>h₃:<{ ∅ / δ ⊢ t₃✝ ⦂ τ✝ }>n✝:Nath₁✝:<{ ∅ / δ ⊢ ~(Tm.const (n✝ + 1)) ⦂ Nat }>h₂_ih✝:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ✝ }> ∧ δ' ⊢ ρh₃_ih✝:∀ {t' : Tm}, t₃✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ✝ }> ∧ δ' ⊢ ρih₁:∀ {t' : Tm}, Tm.const (n✝ + 1) / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ⊢ Extends δ δ ∧ <{ ∅ / δ ⊢ t₃✝ ⦂ τ✝ }> ∧ δ ⊢ ρ; constructor if0Nonzero.left δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextt₂✝:Tmt₃✝:Tmτ✝:Tyh₂:<{ ∅ / δ ⊢ t₂✝ ⦂ τ✝ }>h₃:<{ ∅ / δ ⊢ t₃✝ ⦂ τ✝ }>n✝:Nath₁✝:<{ ∅ / δ ⊢ ~(Tm.const (n✝ + 1)) ⦂ Nat }>h₂_ih✝:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ✝ }> ∧ δ' ⊢ ρh₃_ih✝:∀ {t' : Tm}, t₃✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ✝ }> ∧ δ' ⊢ ρih₁:∀ {t' : Tm}, Tm.const (n✝ + 1) / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ⊢ Extends δ δif0Nonzero.right δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextt₂✝:Tmt₃✝:Tmτ✝:Tyh₂:<{ ∅ / δ ⊢ t₂✝ ⦂ τ✝ }>h₃:<{ ∅ / δ ⊢ t₃✝ ⦂ τ✝ }>n✝:Nath₁✝:<{ ∅ / δ ⊢ ~(Tm.const (n✝ + 1)) ⦂ Nat }>h₂_ih✝:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ✝ }> ∧ δ' ⊢ ρh₃_ih✝:∀ {t' : Tm}, t₃✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ✝ }> ∧ δ' ⊢ ρih₁:∀ {t' : Tm}, Tm.const (n✝ + 1) / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ⊢ <{ ∅ / δ ⊢ t₃✝ ⦂ τ✝ }> ∧ δ ⊢ ρ
apply extends_refl if0Nonzero.right δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextt₂✝:Tmt₃✝:Tmτ✝:Tyh₂:<{ ∅ / δ ⊢ t₂✝ ⦂ τ✝ }>h₃:<{ ∅ / δ ⊢ t₃✝ ⦂ τ✝ }>n✝:Nath₁✝:<{ ∅ / δ ⊢ ~(Tm.const (n✝ + 1)) ⦂ Nat }>h₂_ih✝:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ✝ }> ∧ δ' ⊢ ρh₃_ih✝:∀ {t' : Tm}, t₃✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ✝ }> ∧ δ' ⊢ ρih₁:∀ {t' : Tm}, Tm.const (n✝ + 1) / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ⊢ <{ ∅ / δ ⊢ t₃✝ ⦂ τ✝ }> ∧ δ ⊢ ρ; constructor if0Nonzero.right.left δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextt₂✝:Tmt₃✝:Tmτ✝:Tyh₂:<{ ∅ / δ ⊢ t₂✝ ⦂ τ✝ }>h₃:<{ ∅ / δ ⊢ t₃✝ ⦂ τ✝ }>n✝:Nath₁✝:<{ ∅ / δ ⊢ ~(Tm.const (n✝ + 1)) ⦂ Nat }>h₂_ih✝:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ✝ }> ∧ δ' ⊢ ρh₃_ih✝:∀ {t' : Tm}, t₃✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ✝ }> ∧ δ' ⊢ ρih₁:∀ {t' : Tm}, Tm.const (n✝ + 1) / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ⊢ <{ ∅ / δ ⊢ t₃✝ ⦂ τ✝ }>if0Nonzero.right.right δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextt₂✝:Tmt₃✝:Tmτ✝:Tyh₂:<{ ∅ / δ ⊢ t₂✝ ⦂ τ✝ }>h₃:<{ ∅ / δ ⊢ t₃✝ ⦂ τ✝ }>n✝:Nath₁✝:<{ ∅ / δ ⊢ ~(Tm.const (n✝ + 1)) ⦂ Nat }>h₂_ih✝:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ✝ }> ∧ δ' ⊢ ρh₃_ih✝:∀ {t' : Tm}, t₃✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ✝ }> ∧ δ' ⊢ ρih₁:∀ {t' : Tm}, Tm.const (n✝ + 1) / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ⊢ δ ⊢ ρ <;> if0Nonzero.right.left δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextt₂✝:Tmt₃✝:Tmτ✝:Tyh₂:<{ ∅ / δ ⊢ t₂✝ ⦂ τ✝ }>h₃:<{ ∅ / δ ⊢ t₃✝ ⦂ τ✝ }>n✝:Nath₁✝:<{ ∅ / δ ⊢ ~(Tm.const (n✝ + 1)) ⦂ Nat }>h₂_ih✝:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ✝ }> ∧ δ' ⊢ ρh₃_ih✝:∀ {t' : Tm}, t₃✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ✝ }> ∧ δ' ⊢ ρih₁:∀ {t' : Tm}, Tm.const (n✝ + 1) / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ⊢ <{ ∅ / δ ⊢ t₃✝ ⦂ τ✝ }>if0Nonzero.right.right δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextt₂✝:Tmt₃✝:Tmτ✝:Tyh₂:<{ ∅ / δ ⊢ t₂✝ ⦂ τ✝ }>h₃:<{ ∅ / δ ⊢ t₃✝ ⦂ τ✝ }>n✝:Nath₁✝:<{ ∅ / δ ⊢ ~(Tm.const (n✝ + 1)) ⦂ Nat }>h₂_ih✝:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ✝ }> ∧ δ' ⊢ ρh₃_ih✝:∀ {t' : Tm}, t₃✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ✝ }> ∧ δ' ⊢ ρih₁:∀ {t' : Tm}, Tm.const (n✝ + 1) / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ⊢ δ ⊢ ρ assumption All goals completed! 🐙
| @ref_ _ _ τ₁ h ih => ref_ δ:StoreTyt:Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmτ₁:Tyt':TmhEval:<{ ref t₁✝ }> / ρ ⟶ t' / ρ'h:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₁ }>ih:∀ {t' : Tm}, t₁✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₁ }> ∧ δ' ⊢ ρ'⊢ ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Ref τ₁ }> ∧ δ' ⊢ ρ'
inversion hEval with
| refValue => refValue δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmτ₁:Tyh:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₁ }>h✝:t₁✝.IsValueih:∀ {t' : Tm},
t₁✝ / ρ ⟶ t' / List.concat ρ t₁✝ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₁ }> ∧ δ' ⊢ List.concat ρ t₁✝⊢ ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ ~(Tm.loc (List.length ρ)) ⦂ Ref τ₁ }> ∧ δ' ⊢ List.concat ρ t₁✝
exists δ.concat τ₁ refValue δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmτ₁:Tyh:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₁ }>h✝:t₁✝.IsValueih:∀ {t' : Tm},
t₁✝ / ρ ⟶ t' / List.concat ρ t₁✝ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₁ }> ∧ δ' ⊢ List.concat ρ t₁✝⊢ Extends (List.concat δ τ₁) δ ∧
<{ ∅ / (List.concat δ τ₁) ⊢ ~(Tm.loc (List.length ρ)) ⦂ Ref τ₁ }> ∧ List.concat δ τ₁ ⊢ List.concat ρ t₁✝; constructor refValue.left δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmτ₁:Tyh:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₁ }>h✝:t₁✝.IsValueih:∀ {t' : Tm},
t₁✝ / ρ ⟶ t' / List.concat ρ t₁✝ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₁ }> ∧ δ' ⊢ List.concat ρ t₁✝⊢ Extends (List.concat δ τ₁) δrefValue.right δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmτ₁:Tyh:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₁ }>h✝:t₁✝.IsValueih:∀ {t' : Tm},
t₁✝ / ρ ⟶ t' / List.concat ρ t₁✝ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₁ }> ∧ δ' ⊢ List.concat ρ t₁✝⊢ <{ ∅ / (List.concat δ τ₁) ⊢ ~(Tm.loc (List.length ρ)) ⦂ Ref τ₁ }> ∧ List.concat δ τ₁ ⊢ List.concat ρ t₁✝
· refValue.left δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmτ₁:Tyh:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₁ }>h✝:t₁✝.IsValueih:∀ {t' : Tm},
t₁✝ / ρ ⟶ t' / List.concat ρ t₁✝ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₁ }> ∧ δ' ⊢ List.concat ρ t₁✝⊢ Extends (List.concat δ τ₁) δ rw [List.concat_eq_append refValue.left δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmτ₁:Tyh:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₁ }>h✝:t₁✝.IsValueih:∀ {t' : Tm},
t₁✝ / ρ ⟶ t' / List.concat ρ t₁✝ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₁ }> ∧ δ' ⊢ List.concat ρ t₁✝⊢ Extends (δ ++ [τ₁]) δ] refValue.left δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmτ₁:Tyh:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₁ }>h✝:t₁✝.IsValueih:∀ {t' : Tm},
t₁✝ / ρ ⟶ t' / List.concat ρ t₁✝ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₁ }> ∧ δ' ⊢ List.concat ρ t₁✝⊢ Extends (δ ++ [τ₁]) δ; apply extends_app All goals completed! 🐙
· refValue.right δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmτ₁:Tyh:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₁ }>h✝:t₁✝.IsValueih:∀ {t' : Tm},
t₁✝ / ρ ⟶ t' / List.concat ρ t₁✝ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₁ }> ∧ δ' ⊢ List.concat ρ t₁✝⊢ <{ ∅ / (List.concat δ τ₁) ⊢ ~(Tm.loc (List.length ρ)) ⦂ Ref τ₁ }> ∧ List.concat δ τ₁ ⊢ List.concat ρ t₁✝ constructor refValue.right.left δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmτ₁:Tyh:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₁ }>h✝:t₁✝.IsValueih:∀ {t' : Tm},
t₁✝ / ρ ⟶ t' / List.concat ρ t₁✝ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₁ }> ∧ δ' ⊢ List.concat ρ t₁✝⊢ <{ ∅ / (List.concat δ τ₁) ⊢ ~(Tm.loc (List.length ρ)) ⦂ Ref τ₁ }>refValue.right.right δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmτ₁:Tyh:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₁ }>h✝:t₁✝.IsValueih:∀ {t' : Tm},
t₁✝ / ρ ⟶ t' / List.concat ρ t₁✝ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₁ }> ∧ δ' ⊢ List.concat ρ t₁✝⊢ List.concat δ τ₁ ⊢ List.concat ρ t₁✝
· refValue.right.left δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmτ₁:Tyh:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₁ }>h✝:t₁✝.IsValueih:∀ {t' : Tm},
t₁✝ / ρ ⟶ t' / List.concat ρ t₁✝ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₁ }> ∧ δ' ⊢ List.concat ρ t₁✝⊢ <{ ∅ / (List.concat δ τ₁) ⊢ ~(Tm.loc (List.length ρ)) ⦂ Ref τ₁ }> have h : <{Ref τ₁}> = <{Ref ~((δ.concat τ₁)[ρ.length])}> := by δ:StoreTyt:Tmt':Tmτ:Tyρ:Storeρ':StorehTy:<{ ∅ / δ ⊢ t ⦂ τ }>hStoreTy:δ ⊢ ρhEval:t / ρ ⟶ t' / ρ'⊢ ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ }> ∧ δ' ⊢ ρ'
simp_all [StoreWellTyped, MyGetElem.getElem] refValue.right.left δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmτ₁:Tyh✝¹:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₁ }>h✝:t₁✝.IsValueih:∀ {t' : Tm},
t₁✝ / ρ ⟶ t' / List.concat ρ t₁✝ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₁ }> ∧ δ' ⊢ List.concat ρ t₁✝h:<{ Ref τ₁ }> = <{ Ref ~(List.concat δ τ₁)[List.length ρ] }>⊢ <{ ∅ / (List.concat δ τ₁) ⊢ ~(Tm.loc (List.length ρ)) ⦂ Ref τ₁ }>
rw [h refValue.right.left δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmτ₁:Tyh✝¹:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₁ }>h✝:t₁✝.IsValueih:∀ {t' : Tm},
t₁✝ / ρ ⟶ t' / List.concat ρ t₁✝ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₁ }> ∧ δ' ⊢ List.concat ρ t₁✝h:<{ Ref τ₁ }> = <{ Ref ~(List.concat δ τ₁)[List.length ρ] }>⊢ <{ ∅ / (List.concat δ τ₁) ⊢ ~(Tm.loc (List.length ρ)) ⦂ Ref ~(List.concat δ τ₁)[List.length ρ] }>] refValue.right.left δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmτ₁:Tyh✝¹:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₁ }>h✝:t₁✝.IsValueih:∀ {t' : Tm},
t₁✝ / ρ ⟶ t' / List.concat ρ t₁✝ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₁ }> ∧ δ' ⊢ List.concat ρ t₁✝h:<{ Ref τ₁ }> = <{ Ref ~(List.concat δ τ₁)[List.length ρ] }>⊢ <{ ∅ / (List.concat δ τ₁) ⊢ ~(Tm.loc (List.length ρ)) ⦂ Ref ~(List.concat δ τ₁)[List.length ρ] }>
constructor refValue.right.left δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmτ₁:Tyh✝¹:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₁ }>h✝:t₁✝.IsValueih:∀ {t' : Tm},
t₁✝ / ρ ⟶ t' / List.concat ρ t₁✝ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₁ }> ∧ δ' ⊢ List.concat ρ t₁✝h:<{ Ref τ₁ }> = <{ Ref ~(List.concat δ τ₁)[List.length ρ] }>⊢ List.length ρ < (List.concat δ τ₁).length
simp [StoreWellTyped] at hStoreTy ⊢ refValue.right.left δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:List.length δ = List.length ρ ∧ ∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₁✝:Tmτ₁:Tyh✝¹:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₁ }>h✝:t₁✝.IsValueih:∀ {t' : Tm},
t₁✝ / ρ ⟶ t' / List.concat ρ t₁✝ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₁ }> ∧ δ' ⊢ List.concat ρ t₁✝h:<{ Ref τ₁ }> = <{ Ref ~(List.concat δ τ₁)[List.length ρ] }>⊢ List.length ρ < List.length δ + 1; lia All goals completed! 🐙
· refValue.right.right δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmτ₁:Tyh:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₁ }>h✝:t₁✝.IsValueih:∀ {t' : Tm},
t₁✝ / ρ ⟶ t' / List.concat ρ t₁✝ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₁ }> ∧ δ' ⊢ List.concat ρ t₁✝⊢ List.concat δ τ₁ ⊢ List.concat ρ t₁✝ apply store_well_typed_app refValue.right.right.hStoreTy δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmτ₁:Tyh:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₁ }>h✝:t₁✝.IsValueih:∀ {t' : Tm},
t₁✝ / ρ ⟶ t' / List.concat ρ t₁✝ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₁ }> ∧ δ' ⊢ List.concat ρ t₁✝⊢ δ ⊢ ρrefValue.right.right.hTy δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmτ₁:Tyh:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₁ }>h✝:t₁✝.IsValueih:∀ {t' : Tm},
t₁✝ / ρ ⟶ t' / List.concat ρ t₁✝ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₁ }> ∧ δ' ⊢ List.concat ρ t₁✝⊢ <{ ∅ / δ ⊢ t₁✝ ⦂ τ₁ }> <;> refValue.right.right.hStoreTy δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmτ₁:Tyh:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₁ }>h✝:t₁✝.IsValueih:∀ {t' : Tm},
t₁✝ / ρ ⟶ t' / List.concat ρ t₁✝ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₁ }> ∧ δ' ⊢ List.concat ρ t₁✝⊢ δ ⊢ ρrefValue.right.right.hTy δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmτ₁:Tyh:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₁ }>h✝:t₁✝.IsValueih:∀ {t' : Tm},
t₁✝ / ρ ⟶ t' / List.concat ρ t₁✝ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₁ }> ∧ δ' ⊢ List.concat ρ t₁✝⊢ <{ ∅ / δ ⊢ t₁✝ ⦂ τ₁ }> assumption All goals completed! 🐙
| ref_ hs => ref_ δ:StoreTyt:Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmτ₁:Tyh:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₁ }>ih:∀ {t' : Tm}, t₁✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₁ }> ∧ δ' ⊢ ρ't₁'✝:Tmhs:t₁✝ / ρ ⟶ t₁'✝ / ρ'⊢ ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ ref t₁'✝ ⦂ Ref τ₁ }> ∧ δ' ⊢ ρ'
have ⟨δ', hExt, hTy', hStoreTy'⟩ := ih hs rfl ref_ δ:StoreTyt:Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmτ₁:Tyh:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₁ }>ih:∀ {t' : Tm}, t₁✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₁ }> ∧ δ' ⊢ ρ't₁'✝:Tmhs:t₁✝ / ρ ⟶ t₁'✝ / ρ'δ':StoreTyhExt:Extends δ' δhTy':<{ ∅ / δ' ⊢ t₁'✝ ⦂ τ₁ }>hStoreTy':δ' ⊢ ρ'⊢ ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ ref t₁'✝ ⦂ Ref τ₁ }> ∧ δ' ⊢ ρ'
exists δ' ref_ δ:StoreTyt:Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmτ₁:Tyh:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₁ }>ih:∀ {t' : Tm}, t₁✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₁ }> ∧ δ' ⊢ ρ't₁'✝:Tmhs:t₁✝ / ρ ⟶ t₁'✝ / ρ'δ':StoreTyhExt:Extends δ' δhTy':<{ ∅ / δ' ⊢ t₁'✝ ⦂ τ₁ }>hStoreTy':δ' ⊢ ρ'⊢ Extends δ' δ ∧ <{ ∅ / δ' ⊢ ref t₁'✝ ⦂ Ref τ₁ }> ∧ δ' ⊢ ρ'; constructor ref_.left δ:StoreTyt:Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmτ₁:Tyh:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₁ }>ih:∀ {t' : Tm}, t₁✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₁ }> ∧ δ' ⊢ ρ't₁'✝:Tmhs:t₁✝ / ρ ⟶ t₁'✝ / ρ'δ':StoreTyhExt:Extends δ' δhTy':<{ ∅ / δ' ⊢ t₁'✝ ⦂ τ₁ }>hStoreTy':δ' ⊢ ρ'⊢ Extends δ' δref_.right δ:StoreTyt:Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmτ₁:Tyh:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₁ }>ih:∀ {t' : Tm}, t₁✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₁ }> ∧ δ' ⊢ ρ't₁'✝:Tmhs:t₁✝ / ρ ⟶ t₁'✝ / ρ'δ':StoreTyhExt:Extends δ' δhTy':<{ ∅ / δ' ⊢ t₁'✝ ⦂ τ₁ }>hStoreTy':δ' ⊢ ρ'⊢ <{ ∅ / δ' ⊢ ref t₁'✝ ⦂ Ref τ₁ }> ∧ δ' ⊢ ρ'
assumption ref_.right δ:StoreTyt:Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmτ₁:Tyh:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₁ }>ih:∀ {t' : Tm}, t₁✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₁ }> ∧ δ' ⊢ ρ't₁'✝:Tmhs:t₁✝ / ρ ⟶ t₁'✝ / ρ'δ':StoreTyhExt:Extends δ' δhTy':<{ ∅ / δ' ⊢ t₁'✝ ⦂ τ₁ }>hStoreTy':δ' ⊢ ρ'⊢ <{ ∅ / δ' ⊢ ref t₁'✝ ⦂ Ref τ₁ }> ∧ δ' ⊢ ρ'; constructor ref_.right.left δ:StoreTyt:Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmτ₁:Tyh:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₁ }>ih:∀ {t' : Tm}, t₁✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₁ }> ∧ δ' ⊢ ρ't₁'✝:Tmhs:t₁✝ / ρ ⟶ t₁'✝ / ρ'δ':StoreTyhExt:Extends δ' δhTy':<{ ∅ / δ' ⊢ t₁'✝ ⦂ τ₁ }>hStoreTy':δ' ⊢ ρ'⊢ <{ ∅ / δ' ⊢ ref t₁'✝ ⦂ Ref τ₁ }>ref_.right.right δ:StoreTyt:Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmτ₁:Tyh:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₁ }>ih:∀ {t' : Tm}, t₁✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₁ }> ∧ δ' ⊢ ρ't₁'✝:Tmhs:t₁✝ / ρ ⟶ t₁'✝ / ρ'δ':StoreTyhExt:Extends δ' δhTy':<{ ∅ / δ' ⊢ t₁'✝ ⦂ τ₁ }>hStoreTy':δ' ⊢ ρ'⊢ δ' ⊢ ρ'
solve_by_elim [store_weakening] using StlcRefTyping ref_.right.right δ:StoreTyt:Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmτ₁:Tyh:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₁ }>ih:∀ {t' : Tm}, t₁✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₁ }> ∧ δ' ⊢ ρ't₁'✝:Tmhs:t₁✝ / ρ ⟶ t₁'✝ / ρ'δ':StoreTyhExt:Extends δ' δhTy':<{ ∅ / δ' ⊢ t₁'✝ ⦂ τ₁ }>hStoreTy':δ' ⊢ ρ'⊢ δ' ⊢ ρ'
assumption All goals completed! 🐙
| deref h ih => deref δ:StoreTyt:Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmτ₁✝:Tyt':TmhEval:<{ !t₁✝ }> / ρ ⟶ t' / ρ'h:<{ ∅ / δ ⊢ t₁✝ ⦂ Ref τ₁✝ }>ih:∀ {t' : Tm}, t₁✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Ref τ₁✝ }> ∧ δ' ⊢ ρ'⊢ ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₁✝ }> ∧ δ' ⊢ ρ'
inversion hEval with
| derefLoc hl => derefLoc δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextτ₁✝:Tyl✝:Nath:<{ ∅ / δ ⊢ ~(Tm.loc l✝) ⦂ Ref τ₁✝ }>hl:l✝ < List.length ρih:∀ {t' : Tm}, Tm.loc l✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Ref τ₁✝ }> ∧ δ' ⊢ ρ⊢ ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ ~ρ[l✝] ⦂ τ₁✝ }> ∧ δ' ⊢ ρ
inversion h loc_ δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextl✝:Nathl:l✝ < List.length ρh✝:l✝ < List.length δih:∀ {t' : Tm}, Tm.loc l✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Ref ~δ[l✝] }> ∧ δ' ⊢ ρ⊢ ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ ~ρ[l✝] ⦂ ~δ[l✝] }> ∧ δ' ⊢ ρ
exists δ loc_ δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextl✝:Nathl:l✝ < List.length ρh✝:l✝ < List.length δih:∀ {t' : Tm}, Tm.loc l✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Ref ~δ[l✝] }> ∧ δ' ⊢ ρ⊢ Extends δ δ ∧ <{ ∅ / δ ⊢ ~ρ[l✝] ⦂ ~δ[l✝] }> ∧ δ ⊢ ρ; constructor loc_.left δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextl✝:Nathl:l✝ < List.length ρh✝:l✝ < List.length δih:∀ {t' : Tm}, Tm.loc l✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Ref ~δ[l✝] }> ∧ δ' ⊢ ρ⊢ Extends δ δloc_.right δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextl✝:Nathl:l✝ < List.length ρh✝:l✝ < List.length δih:∀ {t' : Tm}, Tm.loc l✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Ref ~δ[l✝] }> ∧ δ' ⊢ ρ⊢ <{ ∅ / δ ⊢ ~ρ[l✝] ⦂ ~δ[l✝] }> ∧ δ ⊢ ρ
apply extends_refl loc_.right δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextl✝:Nathl:l✝ < List.length ρh✝:l✝ < List.length δih:∀ {t' : Tm}, Tm.loc l✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Ref ~δ[l✝] }> ∧ δ' ⊢ ρ⊢ <{ ∅ / δ ⊢ ~ρ[l✝] ⦂ ~δ[l✝] }> ∧ δ ⊢ ρ; constructor loc_.right.left δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextl✝:Nathl:l✝ < List.length ρh✝:l✝ < List.length δih:∀ {t' : Tm}, Tm.loc l✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Ref ~δ[l✝] }> ∧ δ' ⊢ ρ⊢ <{ ∅ / δ ⊢ ~ρ[l✝] ⦂ ~δ[l✝] }>loc_.right.right δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextl✝:Nathl:l✝ < List.length ρh✝:l✝ < List.length δih:∀ {t' : Tm}, Tm.loc l✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Ref ~δ[l✝] }> ∧ δ' ⊢ ρ⊢ δ ⊢ ρ
have ⟨h₁, h₂⟩ := hStoreTy loc_.right.left δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextl✝:Nathl:l✝ < List.length ρh✝:l✝ < List.length δih:∀ {t' : Tm}, Tm.loc l✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Ref ~δ[l✝] }> ∧ δ' ⊢ ρh₁:List.length δ = List.length ρh₂:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>⊢ <{ ∅ / δ ⊢ ~ρ[l✝] ⦂ ~δ[l✝] }>loc_.right.right δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextl✝:Nathl:l✝ < List.length ρh✝:l✝ < List.length δih:∀ {t' : Tm}, Tm.loc l✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Ref ~δ[l✝] }> ∧ δ' ⊢ ρ⊢ δ ⊢ ρ
apply h₂ loc_.right.left δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextl✝:Nathl:l✝ < List.length ρh✝:l✝ < List.length δih:∀ {t' : Tm}, Tm.loc l✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Ref ~δ[l✝] }> ∧ δ' ⊢ ρh₁:List.length δ = List.length ρh₂:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>⊢ l✝ < List.length ρ <;> loc_.right.left δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextl✝:Nathl:l✝ < List.length ρh✝:l✝ < List.length δih:∀ {t' : Tm}, Tm.loc l✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Ref ~δ[l✝] }> ∧ δ' ⊢ ρh₁:List.length δ = List.length ρh₂:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>⊢ l✝ < List.length ρ assumption All goals completed! 🐙
assumption All goals completed! 🐙
| deref hs => deref δ:StoreTyt:Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmτ₁✝:Tyh:<{ ∅ / δ ⊢ t₁✝ ⦂ Ref τ₁✝ }>ih:∀ {t' : Tm}, t₁✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Ref τ₁✝ }> ∧ δ' ⊢ ρ't₁'✝:Tmhs:t₁✝ / ρ ⟶ t₁'✝ / ρ'⊢ ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ !t₁'✝ ⦂ τ₁✝ }> ∧ δ' ⊢ ρ'
have ⟨δ', hExt, hTy', hStoreTy'⟩ := ih hs rfl deref δ:StoreTyt:Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmτ₁✝:Tyh:<{ ∅ / δ ⊢ t₁✝ ⦂ Ref τ₁✝ }>ih:∀ {t' : Tm}, t₁✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Ref τ₁✝ }> ∧ δ' ⊢ ρ't₁'✝:Tmhs:t₁✝ / ρ ⟶ t₁'✝ / ρ'δ':StoreTyhExt:Extends δ' δhTy':<{ ∅ / δ' ⊢ t₁'✝ ⦂ Ref τ₁✝ }>hStoreTy':δ' ⊢ ρ'⊢ ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ !t₁'✝ ⦂ τ₁✝ }> ∧ δ' ⊢ ρ'
exists δ' deref δ:StoreTyt:Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmτ₁✝:Tyh:<{ ∅ / δ ⊢ t₁✝ ⦂ Ref τ₁✝ }>ih:∀ {t' : Tm}, t₁✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Ref τ₁✝ }> ∧ δ' ⊢ ρ't₁'✝:Tmhs:t₁✝ / ρ ⟶ t₁'✝ / ρ'δ':StoreTyhExt:Extends δ' δhTy':<{ ∅ / δ' ⊢ t₁'✝ ⦂ Ref τ₁✝ }>hStoreTy':δ' ⊢ ρ'⊢ Extends δ' δ ∧ <{ ∅ / δ' ⊢ !t₁'✝ ⦂ τ₁✝ }> ∧ δ' ⊢ ρ'; constructor deref.left δ:StoreTyt:Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmτ₁✝:Tyh:<{ ∅ / δ ⊢ t₁✝ ⦂ Ref τ₁✝ }>ih:∀ {t' : Tm}, t₁✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Ref τ₁✝ }> ∧ δ' ⊢ ρ't₁'✝:Tmhs:t₁✝ / ρ ⟶ t₁'✝ / ρ'δ':StoreTyhExt:Extends δ' δhTy':<{ ∅ / δ' ⊢ t₁'✝ ⦂ Ref τ₁✝ }>hStoreTy':δ' ⊢ ρ'⊢ Extends δ' δderef.right δ:StoreTyt:Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmτ₁✝:Tyh:<{ ∅ / δ ⊢ t₁✝ ⦂ Ref τ₁✝ }>ih:∀ {t' : Tm}, t₁✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Ref τ₁✝ }> ∧ δ' ⊢ ρ't₁'✝:Tmhs:t₁✝ / ρ ⟶ t₁'✝ / ρ'δ':StoreTyhExt:Extends δ' δhTy':<{ ∅ / δ' ⊢ t₁'✝ ⦂ Ref τ₁✝ }>hStoreTy':δ' ⊢ ρ'⊢ <{ ∅ / δ' ⊢ !t₁'✝ ⦂ τ₁✝ }> ∧ δ' ⊢ ρ'
assumption deref.right δ:StoreTyt:Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmτ₁✝:Tyh:<{ ∅ / δ ⊢ t₁✝ ⦂ Ref τ₁✝ }>ih:∀ {t' : Tm}, t₁✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Ref τ₁✝ }> ∧ δ' ⊢ ρ't₁'✝:Tmhs:t₁✝ / ρ ⟶ t₁'✝ / ρ'δ':StoreTyhExt:Extends δ' δhTy':<{ ∅ / δ' ⊢ t₁'✝ ⦂ Ref τ₁✝ }>hStoreTy':δ' ⊢ ρ'⊢ <{ ∅ / δ' ⊢ !t₁'✝ ⦂ τ₁✝ }> ∧ δ' ⊢ ρ'; constructor deref.right.left δ:StoreTyt:Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmτ₁✝:Tyh:<{ ∅ / δ ⊢ t₁✝ ⦂ Ref τ₁✝ }>ih:∀ {t' : Tm}, t₁✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Ref τ₁✝ }> ∧ δ' ⊢ ρ't₁'✝:Tmhs:t₁✝ / ρ ⟶ t₁'✝ / ρ'δ':StoreTyhExt:Extends δ' δhTy':<{ ∅ / δ' ⊢ t₁'✝ ⦂ Ref τ₁✝ }>hStoreTy':δ' ⊢ ρ'⊢ <{ ∅ / δ' ⊢ !t₁'✝ ⦂ τ₁✝ }>deref.right.right δ:StoreTyt:Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmτ₁✝:Tyh:<{ ∅ / δ ⊢ t₁✝ ⦂ Ref τ₁✝ }>ih:∀ {t' : Tm}, t₁✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Ref τ₁✝ }> ∧ δ' ⊢ ρ't₁'✝:Tmhs:t₁✝ / ρ ⟶ t₁'✝ / ρ'δ':StoreTyhExt:Extends δ' δhTy':<{ ∅ / δ' ⊢ t₁'✝ ⦂ Ref τ₁✝ }>hStoreTy':δ' ⊢ ρ'⊢ δ' ⊢ ρ'
solve_by_elim [store_weakening] using StlcRefTyping deref.right.right δ:StoreTyt:Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmτ₁✝:Tyh:<{ ∅ / δ ⊢ t₁✝ ⦂ Ref τ₁✝ }>ih:∀ {t' : Tm}, t₁✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Ref τ₁✝ }> ∧ δ' ⊢ ρ't₁'✝:Tmhs:t₁✝ / ρ ⟶ t₁'✝ / ρ'δ':StoreTyhExt:Extends δ' δhTy':<{ ∅ / δ' ⊢ t₁'✝ ⦂ Ref τ₁✝ }>hStoreTy':δ' ⊢ ρ'⊢ δ' ⊢ ρ'
assumption All goals completed! 🐙
| assign h₁ h₂ ih₁ ih₂ => assign δ:StoreTyt:Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmt₂✝:Tmτ₂✝:Tyt':TmhEval:<{ t₁✝ := t₂✝ }> / ρ ⟶ t' / ρ'h₁:<{ ∅ / δ ⊢ t₁✝ ⦂ Ref τ₂✝ }>h₂:<{ ∅ / δ ⊢ t₂✝ ⦂ τ₂✝ }>ih₁:∀ {t' : Tm}, t₁✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Ref τ₂✝ }> ∧ δ' ⊢ ρ'ih₂:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₂✝ }> ∧ δ' ⊢ ρ'⊢ ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Unit }> ∧ δ' ⊢ ρ'
inversion hEval with
| assign _ hl => assign δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextt₂✝:Tmτ₂✝:Tyh₂:<{ ∅ / δ ⊢ t₂✝ ⦂ τ₂✝ }>l✝:Nath₁:<{ ∅ / δ ⊢ ~(Tm.loc l✝) ⦂ Ref τ₂✝ }>h₁✝:t₂✝.IsValuehl:l✝ < List.length ρih₂:∀ {t' : Tm},
t₂✝ / ρ ⟶ t' / List.set ρ l✝ t₂✝ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₂✝ }> ∧ δ' ⊢ List.set ρ l✝ t₂✝ih₁:∀ {t' : Tm},
Tm.loc l✝ / ρ ⟶ t' / List.set ρ l✝ t₂✝ →
∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Ref τ₂✝ }> ∧ δ' ⊢ List.set ρ l✝ t₂✝⊢ ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ unit ⦂ Unit }> ∧ δ' ⊢ List.set ρ l✝ t₂✝
inversion h₁ loc_ δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextt₂✝:Tml✝:Nath₁✝:t₂✝.IsValuehl:l✝ < List.length ρh✝:l✝ < List.length δh₂:<{ ∅ / δ ⊢ t₂✝ ⦂ ~δ[l✝] }>ih₂:∀ {t' : Tm},
t₂✝ / ρ ⟶ t' / List.set ρ l✝ t₂✝ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ ~δ[l✝] }> ∧ δ' ⊢ List.set ρ l✝ t₂✝ih₁:∀ {t' : Tm},
Tm.loc l✝ / ρ ⟶ t' / List.set ρ l✝ t₂✝ →
∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Ref ~δ[l✝] }> ∧ δ' ⊢ List.set ρ l✝ t₂✝⊢ ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ unit ⦂ Unit }> ∧ δ' ⊢ List.set ρ l✝ t₂✝
exists δ loc_ δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextt₂✝:Tml✝:Nath₁✝:t₂✝.IsValuehl:l✝ < List.length ρh✝:l✝ < List.length δh₂:<{ ∅ / δ ⊢ t₂✝ ⦂ ~δ[l✝] }>ih₂:∀ {t' : Tm},
t₂✝ / ρ ⟶ t' / List.set ρ l✝ t₂✝ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ ~δ[l✝] }> ∧ δ' ⊢ List.set ρ l✝ t₂✝ih₁:∀ {t' : Tm},
Tm.loc l✝ / ρ ⟶ t' / List.set ρ l✝ t₂✝ →
∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Ref ~δ[l✝] }> ∧ δ' ⊢ List.set ρ l✝ t₂✝⊢ Extends δ δ ∧ <{ ∅ / δ ⊢ unit ⦂ Unit }> ∧ δ ⊢ List.set ρ l✝ t₂✝; constructor loc_.left δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextt₂✝:Tml✝:Nath₁✝:t₂✝.IsValuehl:l✝ < List.length ρh✝:l✝ < List.length δh₂:<{ ∅ / δ ⊢ t₂✝ ⦂ ~δ[l✝] }>ih₂:∀ {t' : Tm},
t₂✝ / ρ ⟶ t' / List.set ρ l✝ t₂✝ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ ~δ[l✝] }> ∧ δ' ⊢ List.set ρ l✝ t₂✝ih₁:∀ {t' : Tm},
Tm.loc l✝ / ρ ⟶ t' / List.set ρ l✝ t₂✝ →
∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Ref ~δ[l✝] }> ∧ δ' ⊢ List.set ρ l✝ t₂✝⊢ Extends δ δloc_.right δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextt₂✝:Tml✝:Nath₁✝:t₂✝.IsValuehl:l✝ < List.length ρh✝:l✝ < List.length δh₂:<{ ∅ / δ ⊢ t₂✝ ⦂ ~δ[l✝] }>ih₂:∀ {t' : Tm},
t₂✝ / ρ ⟶ t' / List.set ρ l✝ t₂✝ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ ~δ[l✝] }> ∧ δ' ⊢ List.set ρ l✝ t₂✝ih₁:∀ {t' : Tm},
Tm.loc l✝ / ρ ⟶ t' / List.set ρ l✝ t₂✝ →
∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Ref ~δ[l✝] }> ∧ δ' ⊢ List.set ρ l✝ t₂✝⊢ <{ ∅ / δ ⊢ unit ⦂ Unit }> ∧ δ ⊢ List.set ρ l✝ t₂✝
apply extends_refl loc_.right δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextt₂✝:Tml✝:Nath₁✝:t₂✝.IsValuehl:l✝ < List.length ρh✝:l✝ < List.length δh₂:<{ ∅ / δ ⊢ t₂✝ ⦂ ~δ[l✝] }>ih₂:∀ {t' : Tm},
t₂✝ / ρ ⟶ t' / List.set ρ l✝ t₂✝ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ ~δ[l✝] }> ∧ δ' ⊢ List.set ρ l✝ t₂✝ih₁:∀ {t' : Tm},
Tm.loc l✝ / ρ ⟶ t' / List.set ρ l✝ t₂✝ →
∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Ref ~δ[l✝] }> ∧ δ' ⊢ List.set ρ l✝ t₂✝⊢ <{ ∅ / δ ⊢ unit ⦂ Unit }> ∧ δ ⊢ List.set ρ l✝ t₂✝; constructor loc_.right.left δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextt₂✝:Tml✝:Nath₁✝:t₂✝.IsValuehl:l✝ < List.length ρh✝:l✝ < List.length δh₂:<{ ∅ / δ ⊢ t₂✝ ⦂ ~δ[l✝] }>ih₂:∀ {t' : Tm},
t₂✝ / ρ ⟶ t' / List.set ρ l✝ t₂✝ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ ~δ[l✝] }> ∧ δ' ⊢ List.set ρ l✝ t₂✝ih₁:∀ {t' : Tm},
Tm.loc l✝ / ρ ⟶ t' / List.set ρ l✝ t₂✝ →
∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Ref ~δ[l✝] }> ∧ δ' ⊢ List.set ρ l✝ t₂✝⊢ <{ ∅ / δ ⊢ unit ⦂ Unit }>loc_.right.right δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextt₂✝:Tml✝:Nath₁✝:t₂✝.IsValuehl:l✝ < List.length ρh✝:l✝ < List.length δh₂:<{ ∅ / δ ⊢ t₂✝ ⦂ ~δ[l✝] }>ih₂:∀ {t' : Tm},
t₂✝ / ρ ⟶ t' / List.set ρ l✝ t₂✝ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ ~δ[l✝] }> ∧ δ' ⊢ List.set ρ l✝ t₂✝ih₁:∀ {t' : Tm},
Tm.loc l✝ / ρ ⟶ t' / List.set ρ l✝ t₂✝ →
∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Ref ~δ[l✝] }> ∧ δ' ⊢ List.set ρ l✝ t₂✝⊢ δ ⊢ List.set ρ l✝ t₂✝
constructor loc_.right.right δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextt₂✝:Tml✝:Nath₁✝:t₂✝.IsValuehl:l✝ < List.length ρh✝:l✝ < List.length δh₂:<{ ∅ / δ ⊢ t₂✝ ⦂ ~δ[l✝] }>ih₂:∀ {t' : Tm},
t₂✝ / ρ ⟶ t' / List.set ρ l✝ t₂✝ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ ~δ[l✝] }> ∧ δ' ⊢ List.set ρ l✝ t₂✝ih₁:∀ {t' : Tm},
Tm.loc l✝ / ρ ⟶ t' / List.set ρ l✝ t₂✝ →
∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Ref ~δ[l✝] }> ∧ δ' ⊢ List.set ρ l✝ t₂✝⊢ δ ⊢ List.set ρ l✝ t₂✝
apply assign_pres_store_typing loc_.right.right.hLen δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextt₂✝:Tml✝:Nath₁✝:t₂✝.IsValuehl:l✝ < List.length ρh✝:l✝ < List.length δh₂:<{ ∅ / δ ⊢ t₂✝ ⦂ ~δ[l✝] }>ih₂:∀ {t' : Tm},
t₂✝ / ρ ⟶ t' / List.set ρ l✝ t₂✝ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ ~δ[l✝] }> ∧ δ' ⊢ List.set ρ l✝ t₂✝ih₁:∀ {t' : Tm},
Tm.loc l✝ / ρ ⟶ t' / List.set ρ l✝ t₂✝ →
∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Ref ~δ[l✝] }> ∧ δ' ⊢ List.set ρ l✝ t₂✝⊢ l✝ < List.length ρloc_.right.right.hStoreTy δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextt₂✝:Tml✝:Nath₁✝:t₂✝.IsValuehl:l✝ < List.length ρh✝:l✝ < List.length δh₂:<{ ∅ / δ ⊢ t₂✝ ⦂ ~δ[l✝] }>ih₂:∀ {t' : Tm},
t₂✝ / ρ ⟶ t' / List.set ρ l✝ t₂✝ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ ~δ[l✝] }> ∧ δ' ⊢ List.set ρ l✝ t₂✝ih₁:∀ {t' : Tm},
Tm.loc l✝ / ρ ⟶ t' / List.set ρ l✝ t₂✝ →
∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Ref ~δ[l✝] }> ∧ δ' ⊢ List.set ρ l✝ t₂✝⊢ δ ⊢ ρloc_.right.right.hTy δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextt₂✝:Tml✝:Nath₁✝:t₂✝.IsValuehl:l✝ < List.length ρh✝:l✝ < List.length δh₂:<{ ∅ / δ ⊢ t₂✝ ⦂ ~δ[l✝] }>ih₂:∀ {t' : Tm},
t₂✝ / ρ ⟶ t' / List.set ρ l✝ t₂✝ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ ~δ[l✝] }> ∧ δ' ⊢ List.set ρ l✝ t₂✝ih₁:∀ {t' : Tm},
Tm.loc l✝ / ρ ⟶ t' / List.set ρ l✝ t₂✝ →
∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Ref ~δ[l✝] }> ∧ δ' ⊢ List.set ρ l✝ t₂✝⊢ <{ ∅ / δ ⊢ t₂✝ ⦂ ~δ[l✝] }> <;> loc_.right.right.hLen δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextt₂✝:Tml✝:Nath₁✝:t₂✝.IsValuehl:l✝ < List.length ρh✝:l✝ < List.length δh₂:<{ ∅ / δ ⊢ t₂✝ ⦂ ~δ[l✝] }>ih₂:∀ {t' : Tm},
t₂✝ / ρ ⟶ t' / List.set ρ l✝ t₂✝ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ ~δ[l✝] }> ∧ δ' ⊢ List.set ρ l✝ t₂✝ih₁:∀ {t' : Tm},
Tm.loc l✝ / ρ ⟶ t' / List.set ρ l✝ t₂✝ →
∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Ref ~δ[l✝] }> ∧ δ' ⊢ List.set ρ l✝ t₂✝⊢ l✝ < List.length ρloc_.right.right.hStoreTy δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextt₂✝:Tml✝:Nath₁✝:t₂✝.IsValuehl:l✝ < List.length ρh✝:l✝ < List.length δh₂:<{ ∅ / δ ⊢ t₂✝ ⦂ ~δ[l✝] }>ih₂:∀ {t' : Tm},
t₂✝ / ρ ⟶ t' / List.set ρ l✝ t₂✝ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ ~δ[l✝] }> ∧ δ' ⊢ List.set ρ l✝ t₂✝ih₁:∀ {t' : Tm},
Tm.loc l✝ / ρ ⟶ t' / List.set ρ l✝ t₂✝ →
∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Ref ~δ[l✝] }> ∧ δ' ⊢ List.set ρ l✝ t₂✝⊢ δ ⊢ ρloc_.right.right.hTy δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextt₂✝:Tml✝:Nath₁✝:t₂✝.IsValuehl:l✝ < List.length ρh✝:l✝ < List.length δh₂:<{ ∅ / δ ⊢ t₂✝ ⦂ ~δ[l✝] }>ih₂:∀ {t' : Tm},
t₂✝ / ρ ⟶ t' / List.set ρ l✝ t₂✝ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ ~δ[l✝] }> ∧ δ' ⊢ List.set ρ l✝ t₂✝ih₁:∀ {t' : Tm},
Tm.loc l✝ / ρ ⟶ t' / List.set ρ l✝ t₂✝ →
∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Ref ~δ[l✝] }> ∧ δ' ⊢ List.set ρ l✝ t₂✝⊢ <{ ∅ / δ ⊢ t₂✝ ⦂ ~δ[l✝] }> assumption All goals completed! 🐙
| assign₁ hs => assign₁ δ:StoreTyt:Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmt₂✝:Tmτ₂✝:Tyh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ Ref τ₂✝ }>h₂:<{ ∅ / δ ⊢ t₂✝ ⦂ τ₂✝ }>ih₁:∀ {t' : Tm}, t₁✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Ref τ₂✝ }> ∧ δ' ⊢ ρ'ih₂:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₂✝ }> ∧ δ' ⊢ ρ't₁'✝:Tmhs:t₁✝ / ρ ⟶ t₁'✝ / ρ'⊢ ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t₁'✝ := t₂✝ ⦂ Unit }> ∧ δ' ⊢ ρ'
have ⟨δ', hExt, hTy', hStoreTy'⟩ := ih₁ hs rfl assign₁ δ:StoreTyt:Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmt₂✝:Tmτ₂✝:Tyh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ Ref τ₂✝ }>h₂:<{ ∅ / δ ⊢ t₂✝ ⦂ τ₂✝ }>ih₁:∀ {t' : Tm}, t₁✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Ref τ₂✝ }> ∧ δ' ⊢ ρ'ih₂:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₂✝ }> ∧ δ' ⊢ ρ't₁'✝:Tmhs:t₁✝ / ρ ⟶ t₁'✝ / ρ'δ':StoreTyhExt:Extends δ' δhTy':<{ ∅ / δ' ⊢ t₁'✝ ⦂ Ref τ₂✝ }>hStoreTy':δ' ⊢ ρ'⊢ ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t₁'✝ := t₂✝ ⦂ Unit }> ∧ δ' ⊢ ρ'
exists δ' assign₁ δ:StoreTyt:Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmt₂✝:Tmτ₂✝:Tyh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ Ref τ₂✝ }>h₂:<{ ∅ / δ ⊢ t₂✝ ⦂ τ₂✝ }>ih₁:∀ {t' : Tm}, t₁✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Ref τ₂✝ }> ∧ δ' ⊢ ρ'ih₂:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₂✝ }> ∧ δ' ⊢ ρ't₁'✝:Tmhs:t₁✝ / ρ ⟶ t₁'✝ / ρ'δ':StoreTyhExt:Extends δ' δhTy':<{ ∅ / δ' ⊢ t₁'✝ ⦂ Ref τ₂✝ }>hStoreTy':δ' ⊢ ρ'⊢ Extends δ' δ ∧ <{ ∅ / δ' ⊢ t₁'✝ := t₂✝ ⦂ Unit }> ∧ δ' ⊢ ρ'; constructor assign₁.left δ:StoreTyt:Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmt₂✝:Tmτ₂✝:Tyh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ Ref τ₂✝ }>h₂:<{ ∅ / δ ⊢ t₂✝ ⦂ τ₂✝ }>ih₁:∀ {t' : Tm}, t₁✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Ref τ₂✝ }> ∧ δ' ⊢ ρ'ih₂:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₂✝ }> ∧ δ' ⊢ ρ't₁'✝:Tmhs:t₁✝ / ρ ⟶ t₁'✝ / ρ'δ':StoreTyhExt:Extends δ' δhTy':<{ ∅ / δ' ⊢ t₁'✝ ⦂ Ref τ₂✝ }>hStoreTy':δ' ⊢ ρ'⊢ Extends δ' δassign₁.right δ:StoreTyt:Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmt₂✝:Tmτ₂✝:Tyh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ Ref τ₂✝ }>h₂:<{ ∅ / δ ⊢ t₂✝ ⦂ τ₂✝ }>ih₁:∀ {t' : Tm}, t₁✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Ref τ₂✝ }> ∧ δ' ⊢ ρ'ih₂:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₂✝ }> ∧ δ' ⊢ ρ't₁'✝:Tmhs:t₁✝ / ρ ⟶ t₁'✝ / ρ'δ':StoreTyhExt:Extends δ' δhTy':<{ ∅ / δ' ⊢ t₁'✝ ⦂ Ref τ₂✝ }>hStoreTy':δ' ⊢ ρ'⊢ <{ ∅ / δ' ⊢ t₁'✝ := t₂✝ ⦂ Unit }> ∧ δ' ⊢ ρ'
assumption assign₁.right δ:StoreTyt:Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmt₂✝:Tmτ₂✝:Tyh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ Ref τ₂✝ }>h₂:<{ ∅ / δ ⊢ t₂✝ ⦂ τ₂✝ }>ih₁:∀ {t' : Tm}, t₁✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Ref τ₂✝ }> ∧ δ' ⊢ ρ'ih₂:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₂✝ }> ∧ δ' ⊢ ρ't₁'✝:Tmhs:t₁✝ / ρ ⟶ t₁'✝ / ρ'δ':StoreTyhExt:Extends δ' δhTy':<{ ∅ / δ' ⊢ t₁'✝ ⦂ Ref τ₂✝ }>hStoreTy':δ' ⊢ ρ'⊢ <{ ∅ / δ' ⊢ t₁'✝ := t₂✝ ⦂ Unit }> ∧ δ' ⊢ ρ'; constructor assign₁.right.left δ:StoreTyt:Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmt₂✝:Tmτ₂✝:Tyh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ Ref τ₂✝ }>h₂:<{ ∅ / δ ⊢ t₂✝ ⦂ τ₂✝ }>ih₁:∀ {t' : Tm}, t₁✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Ref τ₂✝ }> ∧ δ' ⊢ ρ'ih₂:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₂✝ }> ∧ δ' ⊢ ρ't₁'✝:Tmhs:t₁✝ / ρ ⟶ t₁'✝ / ρ'δ':StoreTyhExt:Extends δ' δhTy':<{ ∅ / δ' ⊢ t₁'✝ ⦂ Ref τ₂✝ }>hStoreTy':δ' ⊢ ρ'⊢ <{ ∅ / δ' ⊢ t₁'✝ := t₂✝ ⦂ Unit }>assign₁.right.right δ:StoreTyt:Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmt₂✝:Tmτ₂✝:Tyh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ Ref τ₂✝ }>h₂:<{ ∅ / δ ⊢ t₂✝ ⦂ τ₂✝ }>ih₁:∀ {t' : Tm}, t₁✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Ref τ₂✝ }> ∧ δ' ⊢ ρ'ih₂:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₂✝ }> ∧ δ' ⊢ ρ't₁'✝:Tmhs:t₁✝ / ρ ⟶ t₁'✝ / ρ'δ':StoreTyhExt:Extends δ' δhTy':<{ ∅ / δ' ⊢ t₁'✝ ⦂ Ref τ₂✝ }>hStoreTy':δ' ⊢ ρ'⊢ δ' ⊢ ρ'
solve_by_elim [store_weakening] using StlcRefTyping assign₁.right.right δ:StoreTyt:Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmt₂✝:Tmτ₂✝:Tyh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ Ref τ₂✝ }>h₂:<{ ∅ / δ ⊢ t₂✝ ⦂ τ₂✝ }>ih₁:∀ {t' : Tm}, t₁✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Ref τ₂✝ }> ∧ δ' ⊢ ρ'ih₂:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₂✝ }> ∧ δ' ⊢ ρ't₁'✝:Tmhs:t₁✝ / ρ ⟶ t₁'✝ / ρ'δ':StoreTyhExt:Extends δ' δhTy':<{ ∅ / δ' ⊢ t₁'✝ ⦂ Ref τ₂✝ }>hStoreTy':δ' ⊢ ρ'⊢ δ' ⊢ ρ'
assumption All goals completed! 🐙
| assign₂ _ hs => assign₂ δ:StoreTyt:Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmt₂✝:Tmτ₂✝:Tyh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ Ref τ₂✝ }>h₂:<{ ∅ / δ ⊢ t₂✝ ⦂ τ₂✝ }>ih₁:∀ {t' : Tm}, t₁✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Ref τ₂✝ }> ∧ δ' ⊢ ρ'ih₂:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₂✝ }> ∧ δ' ⊢ ρ't₂'✝:Tmh₁✝:t₁✝.IsValuehs:t₂✝ / ρ ⟶ t₂'✝ / ρ'⊢ ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t₁✝ := t₂'✝ ⦂ Unit }> ∧ δ' ⊢ ρ'
have ⟨δ', hExt, hTy', hStoreTy'⟩ := ih₂ hs rfl assign₂ δ:StoreTyt:Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmt₂✝:Tmτ₂✝:Tyh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ Ref τ₂✝ }>h₂:<{ ∅ / δ ⊢ t₂✝ ⦂ τ₂✝ }>ih₁:∀ {t' : Tm}, t₁✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Ref τ₂✝ }> ∧ δ' ⊢ ρ'ih₂:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₂✝ }> ∧ δ' ⊢ ρ't₂'✝:Tmh₁✝:t₁✝.IsValuehs:t₂✝ / ρ ⟶ t₂'✝ / ρ'δ':StoreTyhExt:Extends δ' δhTy':<{ ∅ / δ' ⊢ t₂'✝ ⦂ τ₂✝ }>hStoreTy':δ' ⊢ ρ'⊢ ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t₁✝ := t₂'✝ ⦂ Unit }> ∧ δ' ⊢ ρ'
exists δ' assign₂ δ:StoreTyt:Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmt₂✝:Tmτ₂✝:Tyh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ Ref τ₂✝ }>h₂:<{ ∅ / δ ⊢ t₂✝ ⦂ τ₂✝ }>ih₁:∀ {t' : Tm}, t₁✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Ref τ₂✝ }> ∧ δ' ⊢ ρ'ih₂:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₂✝ }> ∧ δ' ⊢ ρ't₂'✝:Tmh₁✝:t₁✝.IsValuehs:t₂✝ / ρ ⟶ t₂'✝ / ρ'δ':StoreTyhExt:Extends δ' δhTy':<{ ∅ / δ' ⊢ t₂'✝ ⦂ τ₂✝ }>hStoreTy':δ' ⊢ ρ'⊢ Extends δ' δ ∧ <{ ∅ / δ' ⊢ t₁✝ := t₂'✝ ⦂ Unit }> ∧ δ' ⊢ ρ'; constructor assign₂.left δ:StoreTyt:Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmt₂✝:Tmτ₂✝:Tyh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ Ref τ₂✝ }>h₂:<{ ∅ / δ ⊢ t₂✝ ⦂ τ₂✝ }>ih₁:∀ {t' : Tm}, t₁✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Ref τ₂✝ }> ∧ δ' ⊢ ρ'ih₂:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₂✝ }> ∧ δ' ⊢ ρ't₂'✝:Tmh₁✝:t₁✝.IsValuehs:t₂✝ / ρ ⟶ t₂'✝ / ρ'δ':StoreTyhExt:Extends δ' δhTy':<{ ∅ / δ' ⊢ t₂'✝ ⦂ τ₂✝ }>hStoreTy':δ' ⊢ ρ'⊢ Extends δ' δassign₂.right δ:StoreTyt:Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmt₂✝:Tmτ₂✝:Tyh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ Ref τ₂✝ }>h₂:<{ ∅ / δ ⊢ t₂✝ ⦂ τ₂✝ }>ih₁:∀ {t' : Tm}, t₁✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Ref τ₂✝ }> ∧ δ' ⊢ ρ'ih₂:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₂✝ }> ∧ δ' ⊢ ρ't₂'✝:Tmh₁✝:t₁✝.IsValuehs:t₂✝ / ρ ⟶ t₂'✝ / ρ'δ':StoreTyhExt:Extends δ' δhTy':<{ ∅ / δ' ⊢ t₂'✝ ⦂ τ₂✝ }>hStoreTy':δ' ⊢ ρ'⊢ <{ ∅ / δ' ⊢ t₁✝ := t₂'✝ ⦂ Unit }> ∧ δ' ⊢ ρ'
assumption assign₂.right δ:StoreTyt:Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmt₂✝:Tmτ₂✝:Tyh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ Ref τ₂✝ }>h₂:<{ ∅ / δ ⊢ t₂✝ ⦂ τ₂✝ }>ih₁:∀ {t' : Tm}, t₁✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Ref τ₂✝ }> ∧ δ' ⊢ ρ'ih₂:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₂✝ }> ∧ δ' ⊢ ρ't₂'✝:Tmh₁✝:t₁✝.IsValuehs:t₂✝ / ρ ⟶ t₂'✝ / ρ'δ':StoreTyhExt:Extends δ' δhTy':<{ ∅ / δ' ⊢ t₂'✝ ⦂ τ₂✝ }>hStoreTy':δ' ⊢ ρ'⊢ <{ ∅ / δ' ⊢ t₁✝ := t₂'✝ ⦂ Unit }> ∧ δ' ⊢ ρ'; constructor assign₂.right.left δ:StoreTyt:Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmt₂✝:Tmτ₂✝:Tyh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ Ref τ₂✝ }>h₂:<{ ∅ / δ ⊢ t₂✝ ⦂ τ₂✝ }>ih₁:∀ {t' : Tm}, t₁✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Ref τ₂✝ }> ∧ δ' ⊢ ρ'ih₂:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₂✝ }> ∧ δ' ⊢ ρ't₂'✝:Tmh₁✝:t₁✝.IsValuehs:t₂✝ / ρ ⟶ t₂'✝ / ρ'δ':StoreTyhExt:Extends δ' δhTy':<{ ∅ / δ' ⊢ t₂'✝ ⦂ τ₂✝ }>hStoreTy':δ' ⊢ ρ'⊢ <{ ∅ / δ' ⊢ t₁✝ := t₂'✝ ⦂ Unit }>assign₂.right.right δ:StoreTyt:Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmt₂✝:Tmτ₂✝:Tyh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ Ref τ₂✝ }>h₂:<{ ∅ / δ ⊢ t₂✝ ⦂ τ₂✝ }>ih₁:∀ {t' : Tm}, t₁✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Ref τ₂✝ }> ∧ δ' ⊢ ρ'ih₂:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₂✝ }> ∧ δ' ⊢ ρ't₂'✝:Tmh₁✝:t₁✝.IsValuehs:t₂✝ / ρ ⟶ t₂'✝ / ρ'δ':StoreTyhExt:Extends δ' δhTy':<{ ∅ / δ' ⊢ t₂'✝ ⦂ τ₂✝ }>hStoreTy':δ' ⊢ ρ'⊢ δ' ⊢ ρ'
solve_by_elim [store_weakening] using StlcRefTyping assign₂.right.right δ:StoreTyt:Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmt₂✝:Tmτ₂✝:Tyh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ Ref τ₂✝ }>h₂:<{ ∅ / δ ⊢ t₂✝ ⦂ τ₂✝ }>ih₁:∀ {t' : Tm}, t₁✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Ref τ₂✝ }> ∧ δ' ⊢ ρ'ih₂:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₂✝ }> ∧ δ' ⊢ ρ't₂'✝:Tmh₁✝:t₁✝.IsValuehs:t₂✝ / ρ ⟶ t₂'✝ / ρ'δ':StoreTyhExt:Extends δ' δhTy':<{ ∅ / δ' ⊢ t₂'✝ ⦂ τ₂✝ }>hStoreTy':δ' ⊢ ρ'⊢ δ' ⊢ ρ'
assumption All goals completed! 🐙
This proof is pretty long, and many of the cases repeat themselves. With judicious use of automation, we can make it much shorter:
theorem preservation_shorter {δ : StoreTy} {t t' : Tm} {τ : Ty} {ρ ρ' : Store}
(hTy : <{ ∅ / δ ⊢ t ⦂ τ }>)
(hStoreTy : δ ⊢ ρ)
(hEval : t / ρ ⟶ t' / ρ') :
∃ δ', Extends δ' δ ∧ (<{ ∅ / δ' ⊢ t' ⦂ τ }>) ∧ (δ' ⊢ ρ') := by δ:StoreTyt:Tmt':Tmτ:Tyρ:Storeρ':StorehTy:<{ ∅ / δ ⊢ t ⦂ τ }>hStoreTy:δ ⊢ ρhEval:t / ρ ⟶ t' / ρ'⊢ ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ }> ∧ δ' ⊢ ρ'
generalize heq : (∅ : Context) = Γ at hTy δ:StoreTyt:Tmt':Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρhEval:t / ρ ⟶ t' / ρ'Γ:Contextheq:∅ = ΓhTy:<{ Γ / δ ⊢ t ⦂ τ }>⊢ ∃ δ', Extends δ' δ ∧ <{ Γ / δ' ⊢ t' ⦂ τ }> ∧ δ' ⊢ ρ'
induction hTy generalizing t' with (
subst_vars loc_ δ:StoreTyt:Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρΓ:Contextl✝:Nath✝:l✝ < List.length δt':TmhEval:Tm.loc l✝ / ρ ⟶ t' / ρ'⊢ ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Ref ~δ[l✝] }> ∧ δ' ⊢ ρ' <;> loc_ δ:StoreTyt:Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρΓ:Contextl✝:Nath✝:l✝ < List.length δt':TmhEval:Tm.loc l✝ / ρ ⟶ t' / ρ'⊢ ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Ref ~δ[l✝] }> ∧ δ' ⊢ ρ'
-- discharge the goals where `t` doesn't step
inversion hEval All goals completed! 🐙 <;> if0Step δ:StoreTyt:Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmt₂✝:Tmt₃✝:Tmτ✝:Tyh₁✝:<{ ∅ / δ ⊢ t₁✝ ⦂ Nat }>h₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ τ✝ }>h₃✝:<{ ∅ / δ ⊢ t₃✝ ⦂ τ✝ }>h₁_ih✝:∀ {t' : Tm}, t₁✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ'h₂_ih✝:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ✝ }> ∧ δ' ⊢ ρ'h₃_ih✝:∀ {t' : Tm}, t₃✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ✝ }> ∧ δ' ⊢ ρ't₁'✝:Tmh✝:t₁✝ / ρ ⟶ t₁'✝ / ρ'⊢ ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ if0 t₁'✝ then t₂✝ else t₃✝ ⦂ τ✝ }> ∧ δ' ⊢ ρ'if0Zero δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextt₂✝:Tmt₃✝:Tmτ✝:Tyh₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ τ✝ }>h₃✝:<{ ∅ / δ ⊢ t₃✝ ⦂ τ✝ }>h₁✝:<{ ∅ / δ ⊢ 0 ⦂ Nat }>h₂_ih✝:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ✝ }> ∧ δ' ⊢ ρh₃_ih✝:∀ {t' : Tm}, t₃✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ✝ }> ∧ δ' ⊢ ρh₁_ih✝:∀ {t' : Tm}, <{ 0 }> / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ⊢ ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t₂✝ ⦂ τ✝ }> ∧ δ' ⊢ ρif0Nonzero δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextt₂✝:Tmt₃✝:Tmτ✝:Tyh₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ τ✝ }>h₃✝:<{ ∅ / δ ⊢ t₃✝ ⦂ τ✝ }>n✝:Nath₁✝:<{ ∅ / δ ⊢ ~(Tm.const (n✝ + 1)) ⦂ Nat }>h₂_ih✝:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ✝ }> ∧ δ' ⊢ ρh₃_ih✝:∀ {t' : Tm}, t₃✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ✝ }> ∧ δ' ⊢ ρh₁_ih✝:∀ {t' : Tm}, Tm.const (n✝ + 1) / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ⊢ ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t₃✝ ⦂ τ✝ }> ∧ δ' ⊢ ρ
-- handle the congruence cases where the store typing grows,
-- but in an uninteresting way
(try
-- we want to apply our inductive hypotheses, but we can't name
-- them in our automation. Instead, we restate the result that
-- we want and use `solve_by_elim` to figure out how to prove
-- this result using the unnamed `ih`
obtain ⟨δ', hExt, hTy', hStoreTy'⟩ : ∃ δ', Extends δ' δ ∧ _ ∧ (δ' ⊢ ρ') := by δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextt₂✝:Tmt₃✝:Tmτ✝:Tyh₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ τ✝ }>h₃✝:<{ ∅ / δ ⊢ t₃✝ ⦂ τ✝ }>n✝:Nath₁✝:<{ ∅ / δ ⊢ ~(Tm.const (n✝ + 1)) ⦂ Nat }>h₂_ih✝:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ✝ }> ∧ δ' ⊢ ρh₃_ih✝:∀ {t' : Tm}, t₃✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ✝ }> ∧ δ' ⊢ ρh₁_ih✝:∀ {t' : Tm}, Tm.const (n✝ + 1) / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ⊢ ∃ δ', Extends δ' δ ∧ ?m.8154 δ' ∧ δ' ⊢ sorry
solve_by_elim if0Nonzero δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextt₂✝:Tmt₃✝:Tmτ✝:Tyh₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ τ✝ }>h₃✝:<{ ∅ / δ ⊢ t₃✝ ⦂ τ✝ }>n✝:Nath₁✝:<{ ∅ / δ ⊢ ~(Tm.const (n✝ + 1)) ⦂ Nat }>h₂_ih✝:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ✝ }> ∧ δ' ⊢ ρh₃_ih✝:∀ {t' : Tm}, t₃✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ✝ }> ∧ δ' ⊢ ρh₁_ih✝:∀ {t' : Tm}, Tm.const (n✝ + 1) / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρδ':StoreTyhExt:Extends δ' δhTy':sorry δ'hStoreTy':δ' ⊢ sorry⊢ ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t₃✝ ⦂ τ✝ }> ∧ δ' ⊢ ρ
exists δ' if0Nonzero δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextt₂✝:Tmt₃✝:Tmτ✝:Tyh₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ τ✝ }>h₃✝:<{ ∅ / δ ⊢ t₃✝ ⦂ τ✝ }>n✝:Nath₁✝:<{ ∅ / δ ⊢ ~(Tm.const (n✝ + 1)) ⦂ Nat }>h₂_ih✝:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ✝ }> ∧ δ' ⊢ ρh₃_ih✝:∀ {t' : Tm}, t₃✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ✝ }> ∧ δ' ⊢ ρh₁_ih✝:∀ {t' : Tm}, Tm.const (n✝ + 1) / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρδ':StoreTyhExt:Extends δ' δhTy':sorry δ'hStoreTy':δ' ⊢ sorry⊢ Extends δ' δ ∧ <{ ∅ / δ' ⊢ t₃✝ ⦂ τ✝ }> ∧ δ' ⊢ ρ; constructor if0Nonzero.left δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextt₂✝:Tmt₃✝:Tmτ✝:Tyh₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ τ✝ }>h₃✝:<{ ∅ / δ ⊢ t₃✝ ⦂ τ✝ }>n✝:Nath₁✝:<{ ∅ / δ ⊢ ~(Tm.const (n✝ + 1)) ⦂ Nat }>h₂_ih✝:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ✝ }> ∧ δ' ⊢ ρh₃_ih✝:∀ {t' : Tm}, t₃✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ✝ }> ∧ δ' ⊢ ρh₁_ih✝:∀ {t' : Tm}, Tm.const (n✝ + 1) / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρδ':StoreTyhExt:Extends δ' δhTy':sorry δ'hStoreTy':δ' ⊢ sorry⊢ Extends δ' δif0Nonzero.right δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextt₂✝:Tmt₃✝:Tmτ✝:Tyh₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ τ✝ }>h₃✝:<{ ∅ / δ ⊢ t₃✝ ⦂ τ✝ }>n✝:Nath₁✝:<{ ∅ / δ ⊢ ~(Tm.const (n✝ + 1)) ⦂ Nat }>h₂_ih✝:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ✝ }> ∧ δ' ⊢ ρh₃_ih✝:∀ {t' : Tm}, t₃✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ✝ }> ∧ δ' ⊢ ρh₁_ih✝:∀ {t' : Tm}, Tm.const (n✝ + 1) / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρδ':StoreTyhExt:Extends δ' δhTy':sorry δ'hStoreTy':δ' ⊢ sorry⊢ <{ ∅ / δ' ⊢ t₃✝ ⦂ τ✝ }> ∧ δ' ⊢ ρ
assumption if0Nonzero.right δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextt₂✝:Tmt₃✝:Tmτ✝:Tyh₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ τ✝ }>h₃✝:<{ ∅ / δ ⊢ t₃✝ ⦂ τ✝ }>n✝:Nath₁✝:<{ ∅ / δ ⊢ ~(Tm.const (n✝ + 1)) ⦂ Nat }>h₂_ih✝:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ✝ }> ∧ δ' ⊢ ρh₃_ih✝:∀ {t' : Tm}, t₃✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ✝ }> ∧ δ' ⊢ ρh₁_ih✝:∀ {t' : Tm}, Tm.const (n✝ + 1) / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρδ':StoreTyhExt:Extends δ' δhTy':sorry δ'hStoreTy':δ' ⊢ sorry⊢ <{ ∅ / δ' ⊢ t₃✝ ⦂ τ✝ }> ∧ δ' ⊢ ρ; constructor if0Nonzero.right.left δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextt₂✝:Tmt₃✝:Tmτ✝:Tyh₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ τ✝ }>h₃✝:<{ ∅ / δ ⊢ t₃✝ ⦂ τ✝ }>n✝:Nath₁✝:<{ ∅ / δ ⊢ ~(Tm.const (n✝ + 1)) ⦂ Nat }>h₂_ih✝:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ✝ }> ∧ δ' ⊢ ρh₃_ih✝:∀ {t' : Tm}, t₃✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ✝ }> ∧ δ' ⊢ ρh₁_ih✝:∀ {t' : Tm}, Tm.const (n✝ + 1) / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρδ':StoreTyhExt:Extends δ' δhTy':sorry δ'hStoreTy':δ' ⊢ sorry⊢ <{ ∅ / δ' ⊢ t₃✝ ⦂ τ✝ }>if0Nonzero.right.right δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextt₂✝:Tmt₃✝:Tmτ✝:Tyh₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ τ✝ }>h₃✝:<{ ∅ / δ ⊢ t₃✝ ⦂ τ✝ }>n✝:Nath₁✝:<{ ∅ / δ ⊢ ~(Tm.const (n✝ + 1)) ⦂ Nat }>h₂_ih✝:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ✝ }> ∧ δ' ⊢ ρh₃_ih✝:∀ {t' : Tm}, t₃✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ✝ }> ∧ δ' ⊢ ρh₁_ih✝:∀ {t' : Tm}, Tm.const (n✝ + 1) / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρδ':StoreTyhExt:Extends δ' δhTy':sorry δ'hStoreTy':δ' ⊢ sorry⊢ δ' ⊢ ρ
constructor if0Nonzero.right.left δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextt₂✝:Tmt₃✝:Tmτ✝:Tyh₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ τ✝ }>h₃✝:<{ ∅ / δ ⊢ t₃✝ ⦂ τ✝ }>n✝:Nath₁✝:<{ ∅ / δ ⊢ ~(Tm.const (n✝ + 1)) ⦂ Nat }>h₂_ih✝:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ✝ }> ∧ δ' ⊢ ρh₃_ih✝:∀ {t' : Tm}, t₃✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ✝ }> ∧ δ' ⊢ ρh₁_ih✝:∀ {t' : Tm}, Tm.const (n✝ + 1) / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρδ':StoreTyhExt:Extends δ' δhTy':sorry δ'hStoreTy':δ' ⊢ sorry⊢ <{ ∅ / δ' ⊢ t₃✝ ⦂ τ✝ }> <;> if0Step.right.left.h₁ δ:StoreTyt:Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmt₂✝:Tmt₃✝:Tmτ✝:Tyh₁✝:<{ ∅ / δ ⊢ t₁✝ ⦂ Nat }>h₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ τ✝ }>h₃✝:<{ ∅ / δ ⊢ t₃✝ ⦂ τ✝ }>h₁_ih✝:∀ {t' : Tm}, t₁✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ'h₂_ih✝:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ✝ }> ∧ δ' ⊢ ρ'h₃_ih✝:∀ {t' : Tm}, t₃✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ✝ }> ∧ δ' ⊢ ρ't₁'✝:Tmh✝:t₁✝ / ρ ⟶ t₁'✝ / ρ'δ':StoreTyhExt:Extends δ' δhTy':<{ ∅ / δ' ⊢ t₁'✝ ⦂ Nat }>hStoreTy':δ' ⊢ ρ'⊢ <{ ∅ / δ' ⊢ t₁'✝ ⦂ Nat }>if0Step.right.left.h₂ δ:StoreTyt:Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmt₂✝:Tmt₃✝:Tmτ✝:Tyh₁✝:<{ ∅ / δ ⊢ t₁✝ ⦂ Nat }>h₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ τ✝ }>h₃✝:<{ ∅ / δ ⊢ t₃✝ ⦂ τ✝ }>h₁_ih✝:∀ {t' : Tm}, t₁✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ'h₂_ih✝:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ✝ }> ∧ δ' ⊢ ρ'h₃_ih✝:∀ {t' : Tm}, t₃✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ✝ }> ∧ δ' ⊢ ρ't₁'✝:Tmh✝:t₁✝ / ρ ⟶ t₁'✝ / ρ'δ':StoreTyhExt:Extends δ' δhTy':<{ ∅ / δ' ⊢ t₁'✝ ⦂ Nat }>hStoreTy':δ' ⊢ ρ'⊢ <{ ∅ / δ' ⊢ t₂✝ ⦂ τ✝ }>if0Step.right.left.h₃ δ:StoreTyt:Tmτ:Tyρ:Storeρ':StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmt₂✝:Tmt₃✝:Tmτ✝:Tyh₁✝:<{ ∅ / δ ⊢ t₁✝ ⦂ Nat }>h₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ τ✝ }>h₃✝:<{ ∅ / δ ⊢ t₃✝ ⦂ τ✝ }>h₁_ih✝:∀ {t' : Tm}, t₁✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ'h₂_ih✝:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ✝ }> ∧ δ' ⊢ ρ'h₃_ih✝:∀ {t' : Tm}, t₃✝ / ρ ⟶ t' / ρ' → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ✝ }> ∧ δ' ⊢ ρ't₁'✝:Tmh✝:t₁✝ / ρ ⟶ t₁'✝ / ρ'δ':StoreTyhExt:Extends δ' δhTy':<{ ∅ / δ' ⊢ t₁'✝ ⦂ Nat }>hStoreTy':δ' ⊢ ρ'⊢ <{ ∅ / δ' ⊢ t₃✝ ⦂ τ✝ }> solve_by_elim [store_weakening] using StlcRefTyping All goals completed! 🐙
assumption All goals completed! 🐙) <;> if0Zero δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextt₂✝:Tmt₃✝:Tmτ✝:Tyh₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ τ✝ }>h₃✝:<{ ∅ / δ ⊢ t₃✝ ⦂ τ✝ }>h₁✝:<{ ∅ / δ ⊢ 0 ⦂ Nat }>h₂_ih✝:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ✝ }> ∧ δ' ⊢ ρh₃_ih✝:∀ {t' : Tm}, t₃✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ✝ }> ∧ δ' ⊢ ρh₁_ih✝:∀ {t' : Tm}, <{ 0 }> / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ⊢ ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t₂✝ ⦂ τ✝ }> ∧ δ' ⊢ ρif0Nonzero δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextt₂✝:Tmt₃✝:Tmτ✝:Tyh₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ τ✝ }>h₃✝:<{ ∅ / δ ⊢ t₃✝ ⦂ τ✝ }>n✝:Nath₁✝:<{ ∅ / δ ⊢ ~(Tm.const (n✝ + 1)) ⦂ Nat }>h₂_ih✝:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ✝ }> ∧ δ' ⊢ ρh₃_ih✝:∀ {t' : Tm}, t₃✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ✝ }> ∧ δ' ⊢ ρh₁_ih✝:∀ {t' : Tm}, Tm.const (n✝ + 1) / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ⊢ ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t₃✝ ⦂ τ✝ }> ∧ δ' ⊢ ρ
-- handle the cases where the store doesn't grow
(try
exists δ if0Nonzero δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextt₂✝:Tmt₃✝:Tmτ✝:Tyh₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ τ✝ }>h₃✝:<{ ∅ / δ ⊢ t₃✝ ⦂ τ✝ }>n✝:Nath₁✝:<{ ∅ / δ ⊢ ~(Tm.const (n✝ + 1)) ⦂ Nat }>h₂_ih✝:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ✝ }> ∧ δ' ⊢ ρh₃_ih✝:∀ {t' : Tm}, t₃✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ✝ }> ∧ δ' ⊢ ρh₁_ih✝:∀ {t' : Tm}, Tm.const (n✝ + 1) / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ⊢ Extends δ δ ∧ <{ ∅ / δ ⊢ t₃✝ ⦂ τ✝ }> ∧ δ ⊢ ρ; constructor if0Nonzero.left δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextt₂✝:Tmt₃✝:Tmτ✝:Tyh₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ τ✝ }>h₃✝:<{ ∅ / δ ⊢ t₃✝ ⦂ τ✝ }>n✝:Nath₁✝:<{ ∅ / δ ⊢ ~(Tm.const (n✝ + 1)) ⦂ Nat }>h₂_ih✝:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ✝ }> ∧ δ' ⊢ ρh₃_ih✝:∀ {t' : Tm}, t₃✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ✝ }> ∧ δ' ⊢ ρh₁_ih✝:∀ {t' : Tm}, Tm.const (n✝ + 1) / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ⊢ Extends δ δif0Nonzero.right δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextt₂✝:Tmt₃✝:Tmτ✝:Tyh₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ τ✝ }>h₃✝:<{ ∅ / δ ⊢ t₃✝ ⦂ τ✝ }>n✝:Nath₁✝:<{ ∅ / δ ⊢ ~(Tm.const (n✝ + 1)) ⦂ Nat }>h₂_ih✝:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ✝ }> ∧ δ' ⊢ ρh₃_ih✝:∀ {t' : Tm}, t₃✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ✝ }> ∧ δ' ⊢ ρh₁_ih✝:∀ {t' : Tm}, Tm.const (n✝ + 1) / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ⊢ <{ ∅ / δ ⊢ t₃✝ ⦂ τ✝ }> ∧ δ ⊢ ρ
apply extends_refl if0Nonzero.right δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextt₂✝:Tmt₃✝:Tmτ✝:Tyh₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ τ✝ }>h₃✝:<{ ∅ / δ ⊢ t₃✝ ⦂ τ✝ }>n✝:Nath₁✝:<{ ∅ / δ ⊢ ~(Tm.const (n✝ + 1)) ⦂ Nat }>h₂_ih✝:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ✝ }> ∧ δ' ⊢ ρh₃_ih✝:∀ {t' : Tm}, t₃✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ✝ }> ∧ δ' ⊢ ρh₁_ih✝:∀ {t' : Tm}, Tm.const (n✝ + 1) / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ⊢ <{ ∅ / δ ⊢ t₃✝ ⦂ τ✝ }> ∧ δ ⊢ ρ; constructor if0Nonzero.right.left δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextt₂✝:Tmt₃✝:Tmτ✝:Tyh₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ τ✝ }>h₃✝:<{ ∅ / δ ⊢ t₃✝ ⦂ τ✝ }>n✝:Nath₁✝:<{ ∅ / δ ⊢ ~(Tm.const (n✝ + 1)) ⦂ Nat }>h₂_ih✝:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ✝ }> ∧ δ' ⊢ ρh₃_ih✝:∀ {t' : Tm}, t₃✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ✝ }> ∧ δ' ⊢ ρh₁_ih✝:∀ {t' : Tm}, Tm.const (n✝ + 1) / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ⊢ <{ ∅ / δ ⊢ t₃✝ ⦂ τ✝ }>if0Nonzero.right.right δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextt₂✝:Tmt₃✝:Tmτ✝:Tyh₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ τ✝ }>h₃✝:<{ ∅ / δ ⊢ t₃✝ ⦂ τ✝ }>n✝:Nath₁✝:<{ ∅ / δ ⊢ ~(Tm.const (n✝ + 1)) ⦂ Nat }>h₂_ih✝:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ✝ }> ∧ δ' ⊢ ρh₃_ih✝:∀ {t' : Tm}, t₃✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ✝ }> ∧ δ' ⊢ ρh₁_ih✝:∀ {t' : Tm}, Tm.const (n✝ + 1) / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ⊢ δ ⊢ ρ
solve_by_elim using StlcRefTyping if0Nonzero.right.right δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextt₂✝:Tmt₃✝:Tmτ✝:Tyh₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ τ✝ }>h₃✝:<{ ∅ / δ ⊢ t₃✝ ⦂ τ✝ }>n✝:Nath₁✝:<{ ∅ / δ ⊢ ~(Tm.const (n✝ + 1)) ⦂ Nat }>h₂_ih✝:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ✝ }> ∧ δ' ⊢ ρh₃_ih✝:∀ {t' : Tm}, t₃✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ✝ }> ∧ δ' ⊢ ρh₁_ih✝:∀ {t' : Tm}, Tm.const (n✝ + 1) / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Nat }> ∧ δ' ⊢ ρ⊢ δ ⊢ ρ
assumption All goals completed! 🐙))
| app h₁ h₂ ih₁ ih₂ => appAbs δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextτ₁✝:Tyτ₂✝¹:Tyt₂✝:Tmh₂:<{ ∅ / δ ⊢ t₂✝ ⦂ τ₂✝¹ }>x✝:Stringτ₂✝:Tyt₁✝:Tmh₁:<{ ∅ / δ ⊢ λ ~x✝ : τ₂✝ . t₁✝ ⦂ τ₂✝¹ → τ₁✝ }>h✝:t₂✝.IsValueih₂:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₂✝¹ }> ∧ δ' ⊢ ρih₁:∀ {t' : Tm}, <{ λ ~x✝ : τ₂✝ . t₁✝ }> / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₂✝¹ → τ₁✝ }> ∧ δ' ⊢ ρ⊢ ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ [~x✝ := t₂✝] t₁✝ ⦂ τ₁✝ }> ∧ δ' ⊢ ρ
inversion h₁ abs δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextτ₁✝:Tyτ₂✝:Tyt₂✝:Tmh₂:<{ ∅ / δ ⊢ t₂✝ ⦂ τ₂✝¹ }>x✝:Stringt₁✝:Tmh✝¹:t₂✝.IsValueih₂:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₂✝¹ }> ∧ δ' ⊢ ρih₁:∀ {t' : Tm}, <{ λ ~x✝ : τ₂✝ . t₁✝ }> / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₂✝ → τ₁✝ }> ∧ δ' ⊢ ρh✝:<{ ~(x✝ →ₚ τ₂✝) / δ ⊢ t₁✝ ⦂ τ₁✝ }>⊢ ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ [~x✝ := t₂✝] t₁✝ ⦂ τ₁✝ }> ∧ δ' ⊢ ρ
exists δ abs δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextτ₁✝:Tyτ₂✝:Tyt₂✝:Tmh₂:<{ ∅ / δ ⊢ t₂✝ ⦂ τ₂✝¹ }>x✝:Stringt₁✝:Tmh✝¹:t₂✝.IsValueih₂:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₂✝¹ }> ∧ δ' ⊢ ρih₁:∀ {t' : Tm}, <{ λ ~x✝ : τ₂✝ . t₁✝ }> / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₂✝ → τ₁✝ }> ∧ δ' ⊢ ρh✝:<{ ~(x✝ →ₚ τ₂✝) / δ ⊢ t₁✝ ⦂ τ₁✝ }>⊢ Extends δ δ ∧ <{ ∅ / δ ⊢ [~x✝ := t₂✝] t₁✝ ⦂ τ₁✝ }> ∧ δ ⊢ ρ; constructor abs.left δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextτ₁✝:Tyτ₂✝:Tyt₂✝:Tmh₂:<{ ∅ / δ ⊢ t₂✝ ⦂ τ₂✝¹ }>x✝:Stringt₁✝:Tmh✝¹:t₂✝.IsValueih₂:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₂✝¹ }> ∧ δ' ⊢ ρih₁:∀ {t' : Tm}, <{ λ ~x✝ : τ₂✝ . t₁✝ }> / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₂✝ → τ₁✝ }> ∧ δ' ⊢ ρh✝:<{ ~(x✝ →ₚ τ₂✝) / δ ⊢ t₁✝ ⦂ τ₁✝ }>⊢ Extends δ δabs.right δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextτ₁✝:Tyτ₂✝:Tyt₂✝:Tmh₂:<{ ∅ / δ ⊢ t₂✝ ⦂ τ₂✝¹ }>x✝:Stringt₁✝:Tmh✝¹:t₂✝.IsValueih₂:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₂✝¹ }> ∧ δ' ⊢ ρih₁:∀ {t' : Tm}, <{ λ ~x✝ : τ₂✝ . t₁✝ }> / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₂✝ → τ₁✝ }> ∧ δ' ⊢ ρh✝:<{ ~(x✝ →ₚ τ₂✝) / δ ⊢ t₁✝ ⦂ τ₁✝ }>⊢ <{ ∅ / δ ⊢ [~x✝ := t₂✝] t₁✝ ⦂ τ₁✝ }> ∧ δ ⊢ ρ
apply extends_refl abs.right δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextτ₁✝:Tyτ₂✝:Tyt₂✝:Tmh₂:<{ ∅ / δ ⊢ t₂✝ ⦂ τ₂✝¹ }>x✝:Stringt₁✝:Tmh✝¹:t₂✝.IsValueih₂:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₂✝¹ }> ∧ δ' ⊢ ρih₁:∀ {t' : Tm}, <{ λ ~x✝ : τ₂✝ . t₁✝ }> / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₂✝ → τ₁✝ }> ∧ δ' ⊢ ρh✝:<{ ~(x✝ →ₚ τ₂✝) / δ ⊢ t₁✝ ⦂ τ₁✝ }>⊢ <{ ∅ / δ ⊢ [~x✝ := t₂✝] t₁✝ ⦂ τ₁✝ }> ∧ δ ⊢ ρ; constructor abs.right.left δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextτ₁✝:Tyτ₂✝:Tyt₂✝:Tmh₂:<{ ∅ / δ ⊢ t₂✝ ⦂ τ₂✝¹ }>x✝:Stringt₁✝:Tmh✝¹:t₂✝.IsValueih₂:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₂✝¹ }> ∧ δ' ⊢ ρih₁:∀ {t' : Tm}, <{ λ ~x✝ : τ₂✝ . t₁✝ }> / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₂✝ → τ₁✝ }> ∧ δ' ⊢ ρh✝:<{ ~(x✝ →ₚ τ₂✝) / δ ⊢ t₁✝ ⦂ τ₁✝ }>⊢ <{ ∅ / δ ⊢ [~x✝ := t₂✝] t₁✝ ⦂ τ₁✝ }>abs.right.right δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextτ₁✝:Tyτ₂✝:Tyt₂✝:Tmh₂:<{ ∅ / δ ⊢ t₂✝ ⦂ τ₂✝¹ }>x✝:Stringt₁✝:Tmh✝¹:t₂✝.IsValueih₂:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₂✝¹ }> ∧ δ' ⊢ ρih₁:∀ {t' : Tm}, <{ λ ~x✝ : τ₂✝ . t₁✝ }> / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₂✝ → τ₁✝ }> ∧ δ' ⊢ ρh✝:<{ ~(x✝ →ₚ τ₂✝) / δ ⊢ t₁✝ ⦂ τ₁✝ }>⊢ δ ⊢ ρ
apply_rules [substitution_preserves_typing] using StlcRefTyping abs.right.right δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextτ₁✝:Tyτ₂✝:Tyt₂✝:Tmh₂:<{ ∅ / δ ⊢ t₂✝ ⦂ τ₂✝¹ }>x✝:Stringt₁✝:Tmh✝¹:t₂✝.IsValueih₂:∀ {t' : Tm}, t₂✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₂✝¹ }> ∧ δ' ⊢ ρih₁:∀ {t' : Tm}, <{ λ ~x✝ : τ₂✝ . t₁✝ }> / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₂✝ → τ₁✝ }> ∧ δ' ⊢ ρh✝:<{ ~(x✝ →ₚ τ₂✝) / δ ⊢ t₁✝ ⦂ τ₁✝ }>⊢ δ ⊢ ρ
assumption All goals completed! 🐙
| @ref_ _ _ τ₁ => refValue δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmτ₁:Tyh✝¹:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₁ }>h✝:t₁✝.IsValueh_ih✝:∀ {t' : Tm},
t₁✝ / ρ ⟶ t' / List.concat ρ t₁✝ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₁ }> ∧ δ' ⊢ List.concat ρ t₁✝⊢ ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ ~(Tm.loc (List.length ρ)) ⦂ Ref τ₁ }> ∧ δ' ⊢ List.concat ρ t₁✝
exists δ.concat τ₁ refValue δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmτ₁:Tyh✝¹:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₁ }>h✝:t₁✝.IsValueh_ih✝:∀ {t' : Tm},
t₁✝ / ρ ⟶ t' / List.concat ρ t₁✝ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₁ }> ∧ δ' ⊢ List.concat ρ t₁✝⊢ Extends (List.concat δ τ₁) δ ∧
<{ ∅ / (List.concat δ τ₁) ⊢ ~(Tm.loc (List.length ρ)) ⦂ Ref τ₁ }> ∧ List.concat δ τ₁ ⊢ List.concat ρ t₁✝; constructor refValue.left δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmτ₁:Tyh✝¹:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₁ }>h✝:t₁✝.IsValueh_ih✝:∀ {t' : Tm},
t₁✝ / ρ ⟶ t' / List.concat ρ t₁✝ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₁ }> ∧ δ' ⊢ List.concat ρ t₁✝⊢ Extends (List.concat δ τ₁) δrefValue.right δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmτ₁:Tyh✝¹:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₁ }>h✝:t₁✝.IsValueh_ih✝:∀ {t' : Tm},
t₁✝ / ρ ⟶ t' / List.concat ρ t₁✝ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₁ }> ∧ δ' ⊢ List.concat ρ t₁✝⊢ <{ ∅ / (List.concat δ τ₁) ⊢ ~(Tm.loc (List.length ρ)) ⦂ Ref τ₁ }> ∧ List.concat δ τ₁ ⊢ List.concat ρ t₁✝
· refValue.left δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmτ₁:Tyh✝¹:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₁ }>h✝:t₁✝.IsValueh_ih✝:∀ {t' : Tm},
t₁✝ / ρ ⟶ t' / List.concat ρ t₁✝ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₁ }> ∧ δ' ⊢ List.concat ρ t₁✝⊢ Extends (List.concat δ τ₁) δ rw [List.concat_eq_append refValue.left δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmτ₁:Tyh✝¹:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₁ }>h✝:t₁✝.IsValueh_ih✝:∀ {t' : Tm},
t₁✝ / ρ ⟶ t' / List.concat ρ t₁✝ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₁ }> ∧ δ' ⊢ List.concat ρ t₁✝⊢ Extends (δ ++ [τ₁]) δ] refValue.left δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmτ₁:Tyh✝¹:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₁ }>h✝:t₁✝.IsValueh_ih✝:∀ {t' : Tm},
t₁✝ / ρ ⟶ t' / List.concat ρ t₁✝ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₁ }> ∧ δ' ⊢ List.concat ρ t₁✝⊢ Extends (δ ++ [τ₁]) δ; apply extends_app All goals completed! 🐙
· refValue.right δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmτ₁:Tyh✝¹:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₁ }>h✝:t₁✝.IsValueh_ih✝:∀ {t' : Tm},
t₁✝ / ρ ⟶ t' / List.concat ρ t₁✝ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₁ }> ∧ δ' ⊢ List.concat ρ t₁✝⊢ <{ ∅ / (List.concat δ τ₁) ⊢ ~(Tm.loc (List.length ρ)) ⦂ Ref τ₁ }> ∧ List.concat δ τ₁ ⊢ List.concat ρ t₁✝ constructor refValue.right.left δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmτ₁:Tyh✝¹:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₁ }>h✝:t₁✝.IsValueh_ih✝:∀ {t' : Tm},
t₁✝ / ρ ⟶ t' / List.concat ρ t₁✝ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₁ }> ∧ δ' ⊢ List.concat ρ t₁✝⊢ <{ ∅ / (List.concat δ τ₁) ⊢ ~(Tm.loc (List.length ρ)) ⦂ Ref τ₁ }>refValue.right.right δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmτ₁:Tyh✝¹:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₁ }>h✝:t₁✝.IsValueh_ih✝:∀ {t' : Tm},
t₁✝ / ρ ⟶ t' / List.concat ρ t₁✝ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₁ }> ∧ δ' ⊢ List.concat ρ t₁✝⊢ List.concat δ τ₁ ⊢ List.concat ρ t₁✝
· refValue.right.left δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmτ₁:Tyh✝¹:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₁ }>h✝:t₁✝.IsValueh_ih✝:∀ {t' : Tm},
t₁✝ / ρ ⟶ t' / List.concat ρ t₁✝ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₁ }> ∧ δ' ⊢ List.concat ρ t₁✝⊢ <{ ∅ / (List.concat δ τ₁) ⊢ ~(Tm.loc (List.length ρ)) ⦂ Ref τ₁ }> have h : <{Ref τ₁}> = <{Ref ~((δ.concat τ₁)[ρ.length])}> := by δ:StoreTyt:Tmt':Tmτ:Tyρ:Storeρ':StorehTy:<{ ∅ / δ ⊢ t ⦂ τ }>hStoreTy:δ ⊢ ρhEval:t / ρ ⟶ t' / ρ'⊢ ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ }> ∧ δ' ⊢ ρ'
simp_all [StoreWellTyped, MyGetElem.getElem] refValue.right.left δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmτ₁:Tyh✝¹:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₁ }>h✝:t₁✝.IsValueh_ih✝:∀ {t' : Tm},
t₁✝ / ρ ⟶ t' / List.concat ρ t₁✝ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₁ }> ∧ δ' ⊢ List.concat ρ t₁✝h:<{ Ref τ₁ }> = <{ Ref ~(List.concat δ τ₁)[List.length ρ] }>⊢ <{ ∅ / (List.concat δ τ₁) ⊢ ~(Tm.loc (List.length ρ)) ⦂ Ref τ₁ }>
rw [h refValue.right.left δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmτ₁:Tyh✝¹:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₁ }>h✝:t₁✝.IsValueh_ih✝:∀ {t' : Tm},
t₁✝ / ρ ⟶ t' / List.concat ρ t₁✝ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₁ }> ∧ δ' ⊢ List.concat ρ t₁✝h:<{ Ref τ₁ }> = <{ Ref ~(List.concat δ τ₁)[List.length ρ] }>⊢ <{ ∅ / (List.concat δ τ₁) ⊢ ~(Tm.loc (List.length ρ)) ⦂ Ref ~(List.concat δ τ₁)[List.length ρ] }>] refValue.right.left δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmτ₁:Tyh✝¹:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₁ }>h✝:t₁✝.IsValueh_ih✝:∀ {t' : Tm},
t₁✝ / ρ ⟶ t' / List.concat ρ t₁✝ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₁ }> ∧ δ' ⊢ List.concat ρ t₁✝h:<{ Ref τ₁ }> = <{ Ref ~(List.concat δ τ₁)[List.length ρ] }>⊢ <{ ∅ / (List.concat δ τ₁) ⊢ ~(Tm.loc (List.length ρ)) ⦂ Ref ~(List.concat δ τ₁)[List.length ρ] }>
constructor refValue.right.left δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmτ₁:Tyh✝¹:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₁ }>h✝:t₁✝.IsValueh_ih✝:∀ {t' : Tm},
t₁✝ / ρ ⟶ t' / List.concat ρ t₁✝ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₁ }> ∧ δ' ⊢ List.concat ρ t₁✝h:<{ Ref τ₁ }> = <{ Ref ~(List.concat δ τ₁)[List.length ρ] }>⊢ List.length ρ < (List.concat δ τ₁).length
simp [StoreWellTyped] at hStoreTy ⊢ refValue.right.left δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:List.length δ = List.length ρ ∧ ∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₁✝:Tmτ₁:Tyh✝¹:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₁ }>h✝:t₁✝.IsValueh_ih✝:∀ {t' : Tm},
t₁✝ / ρ ⟶ t' / List.concat ρ t₁✝ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₁ }> ∧ δ' ⊢ List.concat ρ t₁✝h:<{ Ref τ₁ }> = <{ Ref ~(List.concat δ τ₁)[List.length ρ] }>⊢ List.length ρ < List.length δ + 1; lia All goals completed! 🐙
· refValue.right.right δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmτ₁:Tyh✝¹:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₁ }>h✝:t₁✝.IsValueh_ih✝:∀ {t' : Tm},
t₁✝ / ρ ⟶ t' / List.concat ρ t₁✝ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₁ }> ∧ δ' ⊢ List.concat ρ t₁✝⊢ List.concat δ τ₁ ⊢ List.concat ρ t₁✝ apply store_well_typed_app refValue.right.right.hStoreTy δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmτ₁:Tyh✝¹:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₁ }>h✝:t₁✝.IsValueh_ih✝:∀ {t' : Tm},
t₁✝ / ρ ⟶ t' / List.concat ρ t₁✝ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₁ }> ∧ δ' ⊢ List.concat ρ t₁✝⊢ δ ⊢ ρrefValue.right.right.hTy δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmτ₁:Tyh✝¹:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₁ }>h✝:t₁✝.IsValueh_ih✝:∀ {t' : Tm},
t₁✝ / ρ ⟶ t' / List.concat ρ t₁✝ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₁ }> ∧ δ' ⊢ List.concat ρ t₁✝⊢ <{ ∅ / δ ⊢ t₁✝ ⦂ τ₁ }> <;> refValue.right.right.hStoreTy δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmτ₁:Tyh✝¹:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₁ }>h✝:t₁✝.IsValueh_ih✝:∀ {t' : Tm},
t₁✝ / ρ ⟶ t' / List.concat ρ t₁✝ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₁ }> ∧ δ' ⊢ List.concat ρ t₁✝⊢ δ ⊢ ρrefValue.right.right.hTy δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextt₁✝:Tmτ₁:Tyh✝¹:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₁ }>h✝:t₁✝.IsValueh_ih✝:∀ {t' : Tm},
t₁✝ / ρ ⟶ t' / List.concat ρ t₁✝ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₁ }> ∧ δ' ⊢ List.concat ρ t₁✝⊢ <{ ∅ / δ ⊢ t₁✝ ⦂ τ₁ }> assumption All goals completed! 🐙
| deref h => derefLoc δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextτ₁✝:Tyl✝:Nath:<{ ∅ / δ ⊢ ~(Tm.loc l✝) ⦂ Ref τ₁✝ }>h✝:l✝ < List.length ρh_ih✝:∀ {t' : Tm}, Tm.loc l✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Ref τ₁✝ }> ∧ δ' ⊢ ρ⊢ ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ ~ρ[l✝] ⦂ τ₁✝ }> ∧ δ' ⊢ ρ
inversion h loc_ δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextl✝:Nath✝¹:l✝ < List.length ρh✝:l✝ < List.length δh_ih✝:∀ {t' : Tm}, Tm.loc l✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Ref ~δ[l✝] }> ∧ δ' ⊢ ρ⊢ ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ ~ρ[l✝] ⦂ ~δ[l✝] }> ∧ δ' ⊢ ρ
exists δ loc_ δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextl✝:Nath✝¹:l✝ < List.length ρh✝:l✝ < List.length δh_ih✝:∀ {t' : Tm}, Tm.loc l✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Ref ~δ[l✝] }> ∧ δ' ⊢ ρ⊢ Extends δ δ ∧ <{ ∅ / δ ⊢ ~ρ[l✝] ⦂ ~δ[l✝] }> ∧ δ ⊢ ρ; constructor loc_.left δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextl✝:Nath✝¹:l✝ < List.length ρh✝:l✝ < List.length δh_ih✝:∀ {t' : Tm}, Tm.loc l✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Ref ~δ[l✝] }> ∧ δ' ⊢ ρ⊢ Extends δ δloc_.right δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextl✝:Nath✝¹:l✝ < List.length ρh✝:l✝ < List.length δh_ih✝:∀ {t' : Tm}, Tm.loc l✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Ref ~δ[l✝] }> ∧ δ' ⊢ ρ⊢ <{ ∅ / δ ⊢ ~ρ[l✝] ⦂ ~δ[l✝] }> ∧ δ ⊢ ρ
apply extends_refl loc_.right δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextl✝:Nath✝¹:l✝ < List.length ρh✝:l✝ < List.length δh_ih✝:∀ {t' : Tm}, Tm.loc l✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Ref ~δ[l✝] }> ∧ δ' ⊢ ρ⊢ <{ ∅ / δ ⊢ ~ρ[l✝] ⦂ ~δ[l✝] }> ∧ δ ⊢ ρ; constructor loc_.right.left δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextl✝:Nath✝¹:l✝ < List.length ρh✝:l✝ < List.length δh_ih✝:∀ {t' : Tm}, Tm.loc l✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Ref ~δ[l✝] }> ∧ δ' ⊢ ρ⊢ <{ ∅ / δ ⊢ ~ρ[l✝] ⦂ ~δ[l✝] }>loc_.right.right δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextl✝:Nath✝¹:l✝ < List.length ρh✝:l✝ < List.length δh_ih✝:∀ {t' : Tm}, Tm.loc l✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Ref ~δ[l✝] }> ∧ δ' ⊢ ρ⊢ δ ⊢ ρ
have ⟨_, h₂⟩ := hStoreTy loc_.right.left δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextl✝:Nath✝¹:l✝ < List.length ρh✝:l✝ < List.length δh_ih✝:∀ {t' : Tm}, Tm.loc l✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Ref ~δ[l✝] }> ∧ δ' ⊢ ρleft✝:List.length δ = List.length ρh₂:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>⊢ <{ ∅ / δ ⊢ ~ρ[l✝] ⦂ ~δ[l✝] }>loc_.right.right δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextl✝:Nath✝¹:l✝ < List.length ρh✝:l✝ < List.length δh_ih✝:∀ {t' : Tm}, Tm.loc l✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Ref ~δ[l✝] }> ∧ δ' ⊢ ρ⊢ δ ⊢ ρ; apply h₂ loc_.right.left δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextl✝:Nath✝¹:l✝ < List.length ρh✝:l✝ < List.length δh_ih✝:∀ {t' : Tm}, Tm.loc l✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Ref ~δ[l✝] }> ∧ δ' ⊢ ρleft✝:List.length δ = List.length ρh₂:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>⊢ l✝ < List.length ρloc_.right.right δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextl✝:Nath✝¹:l✝ < List.length ρh✝:l✝ < List.length δh_ih✝:∀ {t' : Tm}, Tm.loc l✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Ref ~δ[l✝] }> ∧ δ' ⊢ ρ⊢ δ ⊢ ρ; assumption loc_.right.right δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextl✝:Nath✝¹:l✝ < List.length ρh✝:l✝ < List.length δh_ih✝:∀ {t' : Tm}, Tm.loc l✝ / ρ ⟶ t' / ρ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Ref ~δ[l✝] }> ∧ δ' ⊢ ρ⊢ δ ⊢ ρ
assumption All goals completed! 🐙
| assign h₁ => assign δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextt₂✝:Tmτ₂✝:Tyh₂✝¹:<{ ∅ / δ ⊢ t₂✝ ⦂ τ₂✝ }>l✝:Nath₁:<{ ∅ / δ ⊢ ~(Tm.loc l✝) ⦂ Ref τ₂✝ }>h₁✝:t₂✝.IsValueh₂✝:l✝ < List.length ρh₂_ih✝:∀ {t' : Tm},
t₂✝ / ρ ⟶ t' / List.set ρ l✝ t₂✝ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ τ₂✝ }> ∧ δ' ⊢ List.set ρ l✝ t₂✝h₁_ih✝:∀ {t' : Tm},
Tm.loc l✝ / ρ ⟶ t' / List.set ρ l✝ t₂✝ →
∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Ref τ₂✝ }> ∧ δ' ⊢ List.set ρ l✝ t₂✝⊢ ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ unit ⦂ Unit }> ∧ δ' ⊢ List.set ρ l✝ t₂✝
inversion h₁ loc_ δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextt₂✝:Tml✝:Nath₁✝:t₂✝.IsValueh₂✝¹:l✝ < List.length ρh✝:l✝ < List.length δh₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ ~δ[l✝] }>h₂_ih✝:∀ {t' : Tm},
t₂✝ / ρ ⟶ t' / List.set ρ l✝ t₂✝ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ ~δ[l✝] }> ∧ δ' ⊢ List.set ρ l✝ t₂✝h₁_ih✝:∀ {t' : Tm},
Tm.loc l✝ / ρ ⟶ t' / List.set ρ l✝ t₂✝ →
∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Ref ~δ[l✝] }> ∧ δ' ⊢ List.set ρ l✝ t₂✝⊢ ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ unit ⦂ Unit }> ∧ δ' ⊢ List.set ρ l✝ t₂✝
exists δ loc_ δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextt₂✝:Tml✝:Nath₁✝:t₂✝.IsValueh₂✝¹:l✝ < List.length ρh✝:l✝ < List.length δh₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ ~δ[l✝] }>h₂_ih✝:∀ {t' : Tm},
t₂✝ / ρ ⟶ t' / List.set ρ l✝ t₂✝ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ ~δ[l✝] }> ∧ δ' ⊢ List.set ρ l✝ t₂✝h₁_ih✝:∀ {t' : Tm},
Tm.loc l✝ / ρ ⟶ t' / List.set ρ l✝ t₂✝ →
∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Ref ~δ[l✝] }> ∧ δ' ⊢ List.set ρ l✝ t₂✝⊢ Extends δ δ ∧ <{ ∅ / δ ⊢ unit ⦂ Unit }> ∧ δ ⊢ List.set ρ l✝ t₂✝; constructor loc_.left δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextt₂✝:Tml✝:Nath₁✝:t₂✝.IsValueh₂✝¹:l✝ < List.length ρh✝:l✝ < List.length δh₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ ~δ[l✝] }>h₂_ih✝:∀ {t' : Tm},
t₂✝ / ρ ⟶ t' / List.set ρ l✝ t₂✝ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ ~δ[l✝] }> ∧ δ' ⊢ List.set ρ l✝ t₂✝h₁_ih✝:∀ {t' : Tm},
Tm.loc l✝ / ρ ⟶ t' / List.set ρ l✝ t₂✝ →
∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Ref ~δ[l✝] }> ∧ δ' ⊢ List.set ρ l✝ t₂✝⊢ Extends δ δloc_.right δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextt₂✝:Tml✝:Nath₁✝:t₂✝.IsValueh₂✝¹:l✝ < List.length ρh✝:l✝ < List.length δh₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ ~δ[l✝] }>h₂_ih✝:∀ {t' : Tm},
t₂✝ / ρ ⟶ t' / List.set ρ l✝ t₂✝ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ ~δ[l✝] }> ∧ δ' ⊢ List.set ρ l✝ t₂✝h₁_ih✝:∀ {t' : Tm},
Tm.loc l✝ / ρ ⟶ t' / List.set ρ l✝ t₂✝ →
∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Ref ~δ[l✝] }> ∧ δ' ⊢ List.set ρ l✝ t₂✝⊢ <{ ∅ / δ ⊢ unit ⦂ Unit }> ∧ δ ⊢ List.set ρ l✝ t₂✝
apply extends_refl loc_.right δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextt₂✝:Tml✝:Nath₁✝:t₂✝.IsValueh₂✝¹:l✝ < List.length ρh✝:l✝ < List.length δh₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ ~δ[l✝] }>h₂_ih✝:∀ {t' : Tm},
t₂✝ / ρ ⟶ t' / List.set ρ l✝ t₂✝ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ ~δ[l✝] }> ∧ δ' ⊢ List.set ρ l✝ t₂✝h₁_ih✝:∀ {t' : Tm},
Tm.loc l✝ / ρ ⟶ t' / List.set ρ l✝ t₂✝ →
∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Ref ~δ[l✝] }> ∧ δ' ⊢ List.set ρ l✝ t₂✝⊢ <{ ∅ / δ ⊢ unit ⦂ Unit }> ∧ δ ⊢ List.set ρ l✝ t₂✝; constructor loc_.right.left δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextt₂✝:Tml✝:Nath₁✝:t₂✝.IsValueh₂✝¹:l✝ < List.length ρh✝:l✝ < List.length δh₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ ~δ[l✝] }>h₂_ih✝:∀ {t' : Tm},
t₂✝ / ρ ⟶ t' / List.set ρ l✝ t₂✝ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ ~δ[l✝] }> ∧ δ' ⊢ List.set ρ l✝ t₂✝h₁_ih✝:∀ {t' : Tm},
Tm.loc l✝ / ρ ⟶ t' / List.set ρ l✝ t₂✝ →
∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Ref ~δ[l✝] }> ∧ δ' ⊢ List.set ρ l✝ t₂✝⊢ <{ ∅ / δ ⊢ unit ⦂ Unit }>loc_.right.right δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextt₂✝:Tml✝:Nath₁✝:t₂✝.IsValueh₂✝¹:l✝ < List.length ρh✝:l✝ < List.length δh₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ ~δ[l✝] }>h₂_ih✝:∀ {t' : Tm},
t₂✝ / ρ ⟶ t' / List.set ρ l✝ t₂✝ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ ~δ[l✝] }> ∧ δ' ⊢ List.set ρ l✝ t₂✝h₁_ih✝:∀ {t' : Tm},
Tm.loc l✝ / ρ ⟶ t' / List.set ρ l✝ t₂✝ →
∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Ref ~δ[l✝] }> ∧ δ' ⊢ List.set ρ l✝ t₂✝⊢ δ ⊢ List.set ρ l✝ t₂✝
constructor loc_.right.right δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextt₂✝:Tml✝:Nath₁✝:t₂✝.IsValueh₂✝¹:l✝ < List.length ρh✝:l✝ < List.length δh₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ ~δ[l✝] }>h₂_ih✝:∀ {t' : Tm},
t₂✝ / ρ ⟶ t' / List.set ρ l✝ t₂✝ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ ~δ[l✝] }> ∧ δ' ⊢ List.set ρ l✝ t₂✝h₁_ih✝:∀ {t' : Tm},
Tm.loc l✝ / ρ ⟶ t' / List.set ρ l✝ t₂✝ →
∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Ref ~δ[l✝] }> ∧ δ' ⊢ List.set ρ l✝ t₂✝⊢ δ ⊢ List.set ρ l✝ t₂✝
apply assign_pres_store_typing loc_.right.right.hLen δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextt₂✝:Tml✝:Nath₁✝:t₂✝.IsValueh₂✝¹:l✝ < List.length ρh✝:l✝ < List.length δh₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ ~δ[l✝] }>h₂_ih✝:∀ {t' : Tm},
t₂✝ / ρ ⟶ t' / List.set ρ l✝ t₂✝ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ ~δ[l✝] }> ∧ δ' ⊢ List.set ρ l✝ t₂✝h₁_ih✝:∀ {t' : Tm},
Tm.loc l✝ / ρ ⟶ t' / List.set ρ l✝ t₂✝ →
∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Ref ~δ[l✝] }> ∧ δ' ⊢ List.set ρ l✝ t₂✝⊢ l✝ < List.length ρloc_.right.right.hStoreTy δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextt₂✝:Tml✝:Nath₁✝:t₂✝.IsValueh₂✝¹:l✝ < List.length ρh✝:l✝ < List.length δh₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ ~δ[l✝] }>h₂_ih✝:∀ {t' : Tm},
t₂✝ / ρ ⟶ t' / List.set ρ l✝ t₂✝ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ ~δ[l✝] }> ∧ δ' ⊢ List.set ρ l✝ t₂✝h₁_ih✝:∀ {t' : Tm},
Tm.loc l✝ / ρ ⟶ t' / List.set ρ l✝ t₂✝ →
∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Ref ~δ[l✝] }> ∧ δ' ⊢ List.set ρ l✝ t₂✝⊢ δ ⊢ ρloc_.right.right.hTy δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextt₂✝:Tml✝:Nath₁✝:t₂✝.IsValueh₂✝¹:l✝ < List.length ρh✝:l✝ < List.length δh₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ ~δ[l✝] }>h₂_ih✝:∀ {t' : Tm},
t₂✝ / ρ ⟶ t' / List.set ρ l✝ t₂✝ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ ~δ[l✝] }> ∧ δ' ⊢ List.set ρ l✝ t₂✝h₁_ih✝:∀ {t' : Tm},
Tm.loc l✝ / ρ ⟶ t' / List.set ρ l✝ t₂✝ →
∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Ref ~δ[l✝] }> ∧ δ' ⊢ List.set ρ l✝ t₂✝⊢ <{ ∅ / δ ⊢ t₂✝ ⦂ ~δ[l✝] }> <;> loc_.right.right.hLen δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextt₂✝:Tml✝:Nath₁✝:t₂✝.IsValueh₂✝¹:l✝ < List.length ρh✝:l✝ < List.length δh₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ ~δ[l✝] }>h₂_ih✝:∀ {t' : Tm},
t₂✝ / ρ ⟶ t' / List.set ρ l✝ t₂✝ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ ~δ[l✝] }> ∧ δ' ⊢ List.set ρ l✝ t₂✝h₁_ih✝:∀ {t' : Tm},
Tm.loc l✝ / ρ ⟶ t' / List.set ρ l✝ t₂✝ →
∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Ref ~δ[l✝] }> ∧ δ' ⊢ List.set ρ l✝ t₂✝⊢ l✝ < List.length ρloc_.right.right.hStoreTy δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextt₂✝:Tml✝:Nath₁✝:t₂✝.IsValueh₂✝¹:l✝ < List.length ρh✝:l✝ < List.length δh₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ ~δ[l✝] }>h₂_ih✝:∀ {t' : Tm},
t₂✝ / ρ ⟶ t' / List.set ρ l✝ t₂✝ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ ~δ[l✝] }> ∧ δ' ⊢ List.set ρ l✝ t₂✝h₁_ih✝:∀ {t' : Tm},
Tm.loc l✝ / ρ ⟶ t' / List.set ρ l✝ t₂✝ →
∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Ref ~δ[l✝] }> ∧ δ' ⊢ List.set ρ l✝ t₂✝⊢ δ ⊢ ρloc_.right.right.hTy δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρΓ:Contextt₂✝:Tml✝:Nath₁✝:t₂✝.IsValueh₂✝¹:l✝ < List.length ρh✝:l✝ < List.length δh₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ ~δ[l✝] }>h₂_ih✝:∀ {t' : Tm},
t₂✝ / ρ ⟶ t' / List.set ρ l✝ t₂✝ → ∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ ~δ[l✝] }> ∧ δ' ⊢ List.set ρ l✝ t₂✝h₁_ih✝:∀ {t' : Tm},
Tm.loc l✝ / ρ ⟶ t' / List.set ρ l✝ t₂✝ →
∅ = ∅ → ∃ δ', Extends δ' δ ∧ <{ ∅ / δ' ⊢ t' ⦂ Ref ~δ[l✝] }> ∧ δ' ⊢ List.set ρ l✝ t₂✝⊢ <{ ∅ / δ ⊢ t₂✝ ⦂ ~δ[l✝] }> assumption All goals completed! 🐙
This shorter proof only handles the interesting cases (app, deref, assign, and ref)
manually, and solves all the mechanical ones automatically.
Write a careful informal proof of the preservation theorem,
concentrating on the app, deref, assign, and ref
cases.
Proof: By induction on a derivation of ∅ / [] ⊢ t : τ.
-
If the last rule in the derivation is
app, thent = t₁ t₂for somet₁andt₂andτ = τ₁₂, with∅ / δ ⊢ t₁ : τ₁₁ → τ₁₂and∅ / δ ⊢ t₂ : τ₁₁. There are three cases to consider, one for each rule that could have been used to show thatt₁ t₂takes a step tot'.-
Suppose
t₁ t₂takes a step byapp₁, witht₁stepping tot₁'and new storeρ'. Then by the IH there is some store typingδ'such thatδ'extendsδ,ρ'is well typed with respect toδ', and∅ / δ' ⊢ t₁' : τ₁₁ → τ₁₂. We also know∅ / δ' ⊢ t₂ : τ₁₁by thestore_weakeninglemma. Hence,∅ / δ' ⊢ t₁' t₂byapp. -
The
app₂case is similar. -
Suppose
t₁ t₂takes a step byappAbs. Thent₁ = λx:τ₁₁. t₁₂andt₁ t₂steps to[x:=t₂] t₁₂; the desired result now follows from the substitution lemma, takingδ' = δ.
-
-
If the last rule in the derivation is
ref, thent = ref t₁for somet₁and∅ / δ ⊢ t₁ : τ₁for someτ₁, withτ = Ref τ₁. There are two cases to consider, one for each rule that could have been used to show thatref t₁takes a step tot'.-
Suppose
ref t₁takes a step byref, witht₁stepping tot₁'and new storeρ'. Then by the IH there is some store typingδ'such thatδ'extendsδ,ρ'is well typed with respect toδ', and∅ / δ' ⊢ t₁' : τ₁. Hence,∅ / δ' ⊢ ref t₁' : Ref τ₁byref. -
Suppose
ref t₁takes a step byrefValue. Thent₁is a value,ρ' = ρ.concat t₁, andt'is the length ofρ- i.e., the location oft₁inρ'. If we chooseδ' = δ.concat τ₁, we obtain-
δ'extendsδby construction -
ρ'is well typed with respect toδ'becauseρis well typed with respect toδand the last element,t₁, has typeτ₁underδ, hence also underδ'by the store weakening lemma -
∅ / δ' ⊢ l : Ref τ₁bylocas required.
-
-
-
If the last rule in the derivation is
deref, thent = !t₁for somet₁and∅ / δ ⊢ t₁ : Ref τ. There are two cases to consider, one for each rule that could have been used to show that!t₁takes a step tot'.-
Suppose
!t₁takes a step byderef, witht₁stepping tot₁'and new storeρ'. Then by the IH there is some store typingδ'such thatδ'extendsδ,ρ'is well typed with respect toδ', and∅ / δ' ⊢ t₁' : Ref τ. Hence,∅ / δ' ⊢ !t₁' : τbyderef. -
Suppose
ref t₁takes a step byderefLoc. Thent₁is some locationlandt'is the contents ofρat locationl. Moreover, the typing rule used to derive∅ / δ ⊢ l : Ref τmust beloc, so the contents ofδat locationlisτ. Now, sinceρis well typed with respect toδ, we know that∅ / δ ⊢ t' : τ, as required.
-
-
If the last rule in the derivation is
assign, thent = t₁ := t₂for somet₁andt₂, with∅ / δ ⊢ t₁ : Ref τ₂and∅ / δ ⊢ t₂ : τ₂for someτ₂; moreover,τ = Unit. There are now three cases to consider, one for each rule that could have been used to show thatt₁ := t₂takes a step tot'.-
The cases where
t₁ := t₂takes a step by eitherassign₁orassign₂are similar to the congruence rule cases above. -
Suppose
t₁ := t₂takes a step byassign. Thent₁is some locationl,t₂is some value,t'isunit, andρ'is formed fromρby updating the contents of locationlwitht₂.Moreover, the typing rule used to derive
∅ / δ ⊢ l : Ref τ₂must beloc, so the contents ofδat locationlisτ₂. Now,∅ / δ ⊢ unit : Unitbyunit. Moreover, sinceρis well typed with respect toδand we know∅ / δ ⊢ t₂ : τ₂, we know thatρ'is well typed with respect toδby lemmaassign_pres_store_typing. So we can takeδ' = δand finish this case. -
(Other cases elided...)
-
QED.
9.5.4. Progress
As we've said, progress for this system is pretty easy to prove; the proof is very similar to the proof of progress for the STLC, with a few new cases for the new syntactic constructs.
theorem progress (δ : StoreTy) (t : Tm) (τ : Ty) (ρ : Store)
(hTy : <{ ∅ / δ ⊢ t ⦂ τ }>)
(hStoreTy : δ ⊢ ρ) :
(t.IsValue ∨ ∃ t' ρ', t / ρ ⟶ t' / ρ') := by δ:StoreTyt:Tmτ:Tyρ:StorehTy:<{ ∅ / δ ⊢ t ⦂ τ }>hStoreTy:δ ⊢ ρ⊢ t.IsValue ∨ ∃ t' ρ', t / ρ ⟶ t' / ρ'
have ⟨hLen, _⟩ := hStoreTy δ:StoreTyt:Tmτ:Tyρ:StorehTy:<{ ∅ / δ ⊢ t ⦂ τ }>hStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>⊢ t.IsValue ∨ ∃ t' ρ', t / ρ ⟶ t' / ρ'
generalize heq : (∅ : Context) = Γ at hTy δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextheq:∅ = ΓhTy:<{ Γ / δ ⊢ t ⦂ τ }>⊢ t.IsValue ∨ ∃ t' ρ', t / ρ ⟶ t' / ρ'
induction hTy with (subst_vars loc_ δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextl✝:Nath✝:l✝ < List.length δ⊢ (Tm.loc l✝).IsValue ∨ ∃ t' ρ', Tm.loc l✝ / ρ ⟶ t' / ρ'; first
| contradiction loc_ δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextl✝:Nath✝:l✝ < List.length δ⊢ (Tm.loc l✝).IsValue ∨ ∃ t' ρ', Tm.loc l✝ / ρ ⟶ t' / ρ'
-- discharge cases where `t` is obviously a value
| try (left loc_ δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextl✝:Nath✝:l✝ < List.length δ⊢ (Tm.loc l✝).IsValue; constructor All goals completed! 🐙; done))
| app h₁ _ ih₁ ih₂ => app δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextτ₁✝:Tyτ₂✝:Tyt₁✝:Tmt₂✝:Tmh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₂✝ → τ₁✝ }>h₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ τ₂✝ }>ih₁:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'ih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'⊢ <{ t₁✝ t₂✝ }>.IsValue ∨ ∃ t' ρ', <{ t₁✝ t₂✝ }> / ρ ⟶ t' / ρ'
right app δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextτ₁✝:Tyτ₂✝:Tyt₁✝:Tmt₂✝:Tmh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₂✝ → τ₁✝ }>h₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ τ₂✝ }>ih₁:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'ih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'⊢ ∃ t' ρ', <{ t₁✝ t₂✝ }> / ρ ⟶ t' / ρ'; cases ih₁ (by δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextτ₁✝:Tyτ₂✝:Tyt₁✝:Tmt₂✝:Tmh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₂✝ → τ₁✝ }>h₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ τ₂✝ }>ih₁:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'ih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'⊢ ∅ = ∅ rfl All goals completed! 🐙) with
-- t₁ is a value
| inl hv₁ => app.inl δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextτ₁✝:Tyτ₂✝:Tyt₁✝:Tmt₂✝:Tmh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₂✝ → τ₁✝ }>h₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ τ₂✝ }>ih₁:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'ih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'hv₁:t₁✝.IsValue⊢ ∃ t' ρ', <{ t₁✝ t₂✝ }> / ρ ⟶ t' / ρ'
cases ih₂ (by δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextτ₁✝:Tyτ₂✝:Tyt₁✝:Tmt₂✝:Tmh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₂✝ → τ₁✝ }>h₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ τ₂✝ }>ih₁:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'ih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'hv₁:t₁✝.IsValue⊢ ∅ = ∅ rfl All goals completed! 🐙) with
-- t₂ is a value
| inl hv₂ => app.inl.inl δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextτ₁✝:Tyτ₂✝:Tyt₁✝:Tmt₂✝:Tmh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₂✝ → τ₁✝ }>h₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ τ₂✝ }>ih₁:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'ih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'hv₁:t₁✝.IsValuehv₂:t₂✝.IsValue⊢ ∃ t' ρ', <{ t₁✝ t₂✝ }> / ρ ⟶ t' / ρ'
cases hv₁ app.inl.inl.abs δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextτ₁✝:Tyτ₂✝¹:Tyt₂✝:Tmh₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ τ₂✝ }>ih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'hv₂:t₂✝.IsValuex✝:Stringτ₂✝:Tyt₁✝:Tmh₁:<{ ∅ / δ ⊢ λ ~x✝ : τ₂✝ . t₁✝ ⦂ τ₂✝¹ → τ₁✝ }>ih₁:∅ = ∅ → <{ λ ~x✝ : τ₂✝ . t₁✝ }>.IsValue ∨ ∃ t' ρ', <{ λ ~x✝ : τ₂✝ . t₁✝ }> / ρ ⟶ t' / ρ'⊢ ∃ t' ρ', <{ (λ ~x✝ : τ₂✝ . t₁✝) t₂✝ }> / ρ ⟶ t' / ρ'app.inl.inl.nat δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextτ₁✝:Tyτ₂✝:Tyt₂✝:Tmh₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ τ₂✝ }>ih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'hv₂:t₂✝.IsValuen✝:Nath₁:<{ ∅ / δ ⊢ ~(Tm.const n✝) ⦂ τ₂✝ → τ₁✝ }>ih₁:∅ = ∅ → (Tm.const n✝).IsValue ∨ ∃ t' ρ', Tm.const n✝ / ρ ⟶ t' / ρ'⊢ ∃ t' ρ', <{ ~(Tm.const n✝) t₂✝ }> / ρ ⟶ t' / ρ'app.inl.inl.unit δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextτ₁✝:Tyτ₂✝:Tyt₂✝:Tmh₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ τ₂✝ }>ih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'hv₂:t₂✝.IsValueh₁:<{ ∅ / δ ⊢ unit ⦂ τ₂✝ → τ₁✝ }>ih₁:∅ = ∅ → <{ unit }>.IsValue ∨ ∃ t' ρ', <{ unit }> / ρ ⟶ t' / ρ'⊢ ∃ t' ρ', <{ unit t₂✝ }> / ρ ⟶ t' / ρ'app.inl.inl.loc_ δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextτ₁✝:Tyτ₂✝:Tyt₂✝:Tmh₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ τ₂✝ }>ih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'hv₂:t₂✝.IsValuel✝:Nath₁:<{ ∅ / δ ⊢ ~(Tm.loc l✝) ⦂ τ₂✝ → τ₁✝ }>ih₁:∅ = ∅ → (Tm.loc l✝).IsValue ∨ ∃ t' ρ', Tm.loc l✝ / ρ ⟶ t' / ρ'⊢ ∃ t' ρ', <{ ~(Tm.loc l✝) t₂✝ }> / ρ ⟶ t' / ρ' <;> app.inl.inl.abs δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextτ₁✝:Tyτ₂✝¹:Tyt₂✝:Tmh₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ τ₂✝ }>ih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'hv₂:t₂✝.IsValuex✝:Stringτ₂✝:Tyt₁✝:Tmh₁:<{ ∅ / δ ⊢ λ ~x✝ : τ₂✝ . t₁✝ ⦂ τ₂✝¹ → τ₁✝ }>ih₁:∅ = ∅ → <{ λ ~x✝ : τ₂✝ . t₁✝ }>.IsValue ∨ ∃ t' ρ', <{ λ ~x✝ : τ₂✝ . t₁✝ }> / ρ ⟶ t' / ρ'⊢ ∃ t' ρ', <{ (λ ~x✝ : τ₂✝ . t₁✝) t₂✝ }> / ρ ⟶ t' / ρ'app.inl.inl.nat δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextτ₁✝:Tyτ₂✝:Tyt₂✝:Tmh₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ τ₂✝ }>ih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'hv₂:t₂✝.IsValuen✝:Nath₁:<{ ∅ / δ ⊢ ~(Tm.const n✝) ⦂ τ₂✝ → τ₁✝ }>ih₁:∅ = ∅ → (Tm.const n✝).IsValue ∨ ∃ t' ρ', Tm.const n✝ / ρ ⟶ t' / ρ'⊢ ∃ t' ρ', <{ ~(Tm.const n✝) t₂✝ }> / ρ ⟶ t' / ρ'app.inl.inl.unit δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextτ₁✝:Tyτ₂✝:Tyt₂✝:Tmh₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ τ₂✝ }>ih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'hv₂:t₂✝.IsValueh₁:<{ ∅ / δ ⊢ unit ⦂ τ₂✝ → τ₁✝ }>ih₁:∅ = ∅ → <{ unit }>.IsValue ∨ ∃ t' ρ', <{ unit }> / ρ ⟶ t' / ρ'⊢ ∃ t' ρ', <{ unit t₂✝ }> / ρ ⟶ t' / ρ'app.inl.inl.loc_ δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextτ₁✝:Tyτ₂✝:Tyt₂✝:Tmh₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ τ₂✝ }>ih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'hv₂:t₂✝.IsValuel✝:Nath₁:<{ ∅ / δ ⊢ ~(Tm.loc l✝) ⦂ τ₂✝ → τ₁✝ }>ih₁:∅ = ∅ → (Tm.loc l✝).IsValue ∨ ∃ t' ρ', Tm.loc l✝ / ρ ⟶ t' / ρ'⊢ ∃ t' ρ', <{ ~(Tm.loc l✝) t₂✝ }> / ρ ⟶ t' / ρ' try contradiction All goals completed! 🐙
apply Exists.intro app.inl.inl.abs.h δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextτ₁✝:Tyτ₂✝¹:Tyt₂✝:Tmh₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ τ₂✝ }>ih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'hv₂:t₂✝.IsValuex✝:Stringτ₂✝:Tyt₁✝:Tmh₁:<{ ∅ / δ ⊢ λ ~x✝ : τ₂✝ . t₁✝ ⦂ τ₂✝¹ → τ₁✝ }>ih₁:∅ = ∅ → <{ λ ~x✝ : τ₂✝ . t₁✝ }>.IsValue ∨ ∃ t' ρ', <{ λ ~x✝ : τ₂✝ . t₁✝ }> / ρ ⟶ t' / ρ'⊢ ∃ ρ', <{ (λ ~x✝ : τ₂✝ . t₁✝) t₂✝ }> / ρ ⟶ ?app.inl.inl.abs.w / ρ'app.inl.inl.abs.w δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextτ₁✝:Tyτ₂✝¹:Tyt₂✝:Tmh₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ τ₂✝ }>ih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'hv₂:t₂✝.IsValuex✝:Stringτ₂✝:Tyt₁✝:Tmh₁:<{ ∅ / δ ⊢ λ ~x✝ : τ₂✝ . t₁✝ ⦂ τ₂✝¹ → τ₁✝ }>ih₁:∅ = ∅ → <{ λ ~x✝ : τ₂✝ . t₁✝ }>.IsValue ∨ ∃ t' ρ', <{ λ ~x✝ : τ₂✝ . t₁✝ }> / ρ ⟶ t' / ρ'⊢ Tm; apply Exists.intro app.inl.inl.abs.h.h δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextτ₁✝:Tyτ₂✝¹:Tyt₂✝:Tmh₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ τ₂✝ }>ih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'hv₂:t₂✝.IsValuex✝:Stringτ₂✝:Tyt₁✝:Tmh₁:<{ ∅ / δ ⊢ λ ~x✝ : τ₂✝ . t₁✝ ⦂ τ₂✝¹ → τ₁✝ }>ih₁:∅ = ∅ → <{ λ ~x✝ : τ₂✝ . t₁✝ }>.IsValue ∨ ∃ t' ρ', <{ λ ~x✝ : τ₂✝ . t₁✝ }> / ρ ⟶ t' / ρ'⊢ <{ (λ ~x✝ : τ₂✝ . t₁✝) t₂✝ }> / ρ ⟶ ?app.inl.inl.abs.w / ?app.inl.inl.abs.h.wapp.inl.inl.abs.h.w δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextτ₁✝:Tyτ₂✝¹:Tyt₂✝:Tmh₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ τ₂✝ }>ih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'hv₂:t₂✝.IsValuex✝:Stringτ₂✝:Tyt₁✝:Tmh₁:<{ ∅ / δ ⊢ λ ~x✝ : τ₂✝ . t₁✝ ⦂ τ₂✝¹ → τ₁✝ }>ih₁:∅ = ∅ → <{ λ ~x✝ : τ₂✝ . t₁✝ }>.IsValue ∨ ∃ t' ρ', <{ λ ~x✝ : τ₂✝ . t₁✝ }> / ρ ⟶ t' / ρ'⊢ Storeapp.inl.inl.abs.w δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextτ₁✝:Tyτ₂✝¹:Tyt₂✝:Tmh₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ τ₂✝ }>ih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'hv₂:t₂✝.IsValuex✝:Stringτ₂✝:Tyt₁✝:Tmh₁:<{ ∅ / δ ⊢ λ ~x✝ : τ₂✝ . t₁✝ ⦂ τ₂✝¹ → τ₁✝ }>ih₁:∅ = ∅ → <{ λ ~x✝ : τ₂✝ . t₁✝ }>.IsValue ∨ ∃ t' ρ', <{ λ ~x✝ : τ₂✝ . t₁✝ }> / ρ ⟶ t' / ρ'⊢ Tm; solve_by_elim using StlcRefEval All goals completed! 🐙
-- t₂ steps
| inr hs₂ => app.inl.inr δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextτ₁✝:Tyτ₂✝:Tyt₁✝:Tmt₂✝:Tmh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₂✝ → τ₁✝ }>h₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ τ₂✝ }>ih₁:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'ih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'hv₁:t₁✝.IsValuehs₂:∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'⊢ ∃ t' ρ', <{ t₁✝ t₂✝ }> / ρ ⟶ t' / ρ'
have ⟨t₂', ρ', hs₂⟩ := hs₂ app.inl.inr δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextτ₁✝:Tyτ₂✝:Tyt₁✝:Tmt₂✝:Tmh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₂✝ → τ₁✝ }>h₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ τ₂✝ }>ih₁:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'ih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'hv₁:t₁✝.IsValuehs₂✝:∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ't₂':Tmρ':Storehs₂:t₂✝ / ρ ⟶ t₂' / ρ'⊢ ∃ t' ρ', <{ t₁✝ t₂✝ }> / ρ ⟶ t' / ρ'
apply Exists.intro app.inl.inr.h δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextτ₁✝:Tyτ₂✝:Tyt₁✝:Tmt₂✝:Tmh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₂✝ → τ₁✝ }>h₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ τ₂✝ }>ih₁:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'ih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'hv₁:t₁✝.IsValuehs₂✝:∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ't₂':Tmρ':Storehs₂:t₂✝ / ρ ⟶ t₂' / ρ'⊢ ∃ ρ', <{ t₁✝ t₂✝ }> / ρ ⟶ ?app.inl.inr.w / ρ'app.inl.inr.w δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextτ₁✝:Tyτ₂✝:Tyt₁✝:Tmt₂✝:Tmh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₂✝ → τ₁✝ }>h₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ τ₂✝ }>ih₁:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'ih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'hv₁:t₁✝.IsValuehs₂✝:∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ't₂':Tmρ':Storehs₂:t₂✝ / ρ ⟶ t₂' / ρ'⊢ Tm; apply Exists.intro app.inl.inr.h.h δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextτ₁✝:Tyτ₂✝:Tyt₁✝:Tmt₂✝:Tmh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₂✝ → τ₁✝ }>h₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ τ₂✝ }>ih₁:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'ih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'hv₁:t₁✝.IsValuehs₂✝:∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ't₂':Tmρ':Storehs₂:t₂✝ / ρ ⟶ t₂' / ρ'⊢ <{ t₁✝ t₂✝ }> / ρ ⟶ ?app.inl.inr.w / ?app.inl.inr.h.wapp.inl.inr.h.w δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextτ₁✝:Tyτ₂✝:Tyt₁✝:Tmt₂✝:Tmh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₂✝ → τ₁✝ }>h₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ τ₂✝ }>ih₁:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'ih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'hv₁:t₁✝.IsValuehs₂✝:∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ't₂':Tmρ':Storehs₂:t₂✝ / ρ ⟶ t₂' / ρ'⊢ Storeapp.inl.inr.w δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextτ₁✝:Tyτ₂✝:Tyt₁✝:Tmt₂✝:Tmh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₂✝ → τ₁✝ }>h₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ τ₂✝ }>ih₁:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'ih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'hv₁:t₁✝.IsValuehs₂✝:∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ't₂':Tmρ':Storehs₂:t₂✝ / ρ ⟶ t₂' / ρ'⊢ Tm; solve_by_elim using StlcRefEval All goals completed! 🐙
-- t₁ steps
| inr hs₁ => app.inr δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextτ₁✝:Tyτ₂✝:Tyt₁✝:Tmt₂✝:Tmh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₂✝ → τ₁✝ }>h₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ τ₂✝ }>ih₁:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'ih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'hs₁:∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'⊢ ∃ t' ρ', <{ t₁✝ t₂✝ }> / ρ ⟶ t' / ρ'
have ⟨t₁', ρ', hs₁⟩ := hs₁ app.inr δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextτ₁✝:Tyτ₂✝:Tyt₁✝:Tmt₂✝:Tmh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₂✝ → τ₁✝ }>h₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ τ₂✝ }>ih₁:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'ih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'hs₁✝:∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ't₁':Tmρ':Storehs₁:t₁✝ / ρ ⟶ t₁' / ρ'⊢ ∃ t' ρ', <{ t₁✝ t₂✝ }> / ρ ⟶ t' / ρ'
apply Exists.intro app.inr.h δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextτ₁✝:Tyτ₂✝:Tyt₁✝:Tmt₂✝:Tmh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₂✝ → τ₁✝ }>h₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ τ₂✝ }>ih₁:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'ih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'hs₁✝:∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ't₁':Tmρ':Storehs₁:t₁✝ / ρ ⟶ t₁' / ρ'⊢ ∃ ρ', <{ t₁✝ t₂✝ }> / ρ ⟶ ?app.inr.w / ρ'app.inr.w δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextτ₁✝:Tyτ₂✝:Tyt₁✝:Tmt₂✝:Tmh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₂✝ → τ₁✝ }>h₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ τ₂✝ }>ih₁:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'ih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'hs₁✝:∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ't₁':Tmρ':Storehs₁:t₁✝ / ρ ⟶ t₁' / ρ'⊢ Tm; apply Exists.intro app.inr.h.h δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextτ₁✝:Tyτ₂✝:Tyt₁✝:Tmt₂✝:Tmh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₂✝ → τ₁✝ }>h₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ τ₂✝ }>ih₁:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'ih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'hs₁✝:∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ't₁':Tmρ':Storehs₁:t₁✝ / ρ ⟶ t₁' / ρ'⊢ <{ t₁✝ t₂✝ }> / ρ ⟶ ?app.inr.w / ?app.inr.h.wapp.inr.h.w δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextτ₁✝:Tyτ₂✝:Tyt₁✝:Tmt₂✝:Tmh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₂✝ → τ₁✝ }>h₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ τ₂✝ }>ih₁:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'ih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'hs₁✝:∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ't₁':Tmρ':Storehs₁:t₁✝ / ρ ⟶ t₁' / ρ'⊢ Storeapp.inr.w δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextτ₁✝:Tyτ₂✝:Tyt₁✝:Tmt₂✝:Tmh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₂✝ → τ₁✝ }>h₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ τ₂✝ }>ih₁:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'ih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'hs₁✝:∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ't₁':Tmρ':Storehs₁:t₁✝ / ρ ⟶ t₁' / ρ'⊢ Tm; solve_by_elim using StlcRefEval All goals completed! 🐙
| succ h ih succ δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₁✝:Tmh:<{ ∅ / δ ⊢ t₁✝ ⦂ Nat }>ih:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'⊢ <{ succ t₁✝ }>.IsValue ∨ ∃ t' ρ', <{ succ t₁✝ }> / ρ ⟶ t' / ρ'
| pred h ih pred δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₁✝:Tmh:<{ ∅ / δ ⊢ t₁✝ ⦂ Nat }>ih:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'⊢ <{ pred t₁✝ }>.IsValue ∨ ∃ t' ρ', <{ pred t₁✝ }> / ρ ⟶ t' / ρ' => pred δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₁✝:Tmh:<{ ∅ / δ ⊢ t₁✝ ⦂ Nat }>ih:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'⊢ <{ pred t₁✝ }>.IsValue ∨ ∃ t' ρ', <{ pred t₁✝ }> / ρ ⟶ t' / ρ'succ δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₁✝:Tmh:<{ ∅ / δ ⊢ t₁✝ ⦂ Nat }>ih:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'⊢ <{ succ t₁✝ }>.IsValue ∨ ∃ t' ρ', <{ succ t₁✝ }> / ρ ⟶ t' / ρ'
-- these two cases are the same
right pred δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₁✝:Tmh:<{ ∅ / δ ⊢ t₁✝ ⦂ Nat }>ih:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'⊢ ∃ t' ρ', <{ pred t₁✝ }> / ρ ⟶ t' / ρ'; cases ih (by δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₁✝:Tmh:<{ ∅ / δ ⊢ t₁✝ ⦂ Nat }>ih:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'⊢ ∅ = ∅ rfl All goals completed! 🐙) with
-- t₁ is a value
| inl hv => pred.inl δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₁✝:Tmh:<{ ∅ / δ ⊢ t₁✝ ⦂ Nat }>ih:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'hv:t₁✝.IsValue⊢ ∃ t' ρ', <{ pred t₁✝ }> / ρ ⟶ t' / ρ'succ.inl δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₁✝:Tmh:<{ ∅ / δ ⊢ t₁✝ ⦂ Nat }>ih:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'hv:t₁✝.IsValue⊢ ∃ t' ρ', <{ succ t₁✝ }> / ρ ⟶ t' / ρ'
cases hv pred.inl.abs δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextx✝:Stringτ₂✝:Tyt₁✝:Tmh:<{ ∅ / δ ⊢ λ ~x✝ : τ₂✝ . t₁✝ ⦂ Nat }>ih:∅ = ∅ → <{ λ ~x✝ : τ₂✝ . t₁✝ }>.IsValue ∨ ∃ t' ρ', <{ λ ~x✝ : τ₂✝ . t₁✝ }> / ρ ⟶ t' / ρ'⊢ ∃ t' ρ', <{ pred (λ ~x✝ : τ₂✝ . t₁✝) }> / ρ ⟶ t' / ρ'pred.inl.nat δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextn✝:Nath:<{ ∅ / δ ⊢ ~(Tm.const n✝) ⦂ Nat }>ih:∅ = ∅ → (Tm.const n✝).IsValue ∨ ∃ t' ρ', Tm.const n✝ / ρ ⟶ t' / ρ'⊢ ∃ t' ρ', <{ pred ~(Tm.const n✝) }> / ρ ⟶ t' / ρ'pred.inl.unit δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contexth:<{ ∅ / δ ⊢ unit ⦂ Nat }>ih:∅ = ∅ → <{ unit }>.IsValue ∨ ∃ t' ρ', <{ unit }> / ρ ⟶ t' / ρ'⊢ ∃ t' ρ', <{ pred unit }> / ρ ⟶ t' / ρ'pred.inl.loc_ δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextl✝:Nath:<{ ∅ / δ ⊢ ~(Tm.loc l✝) ⦂ Nat }>ih:∅ = ∅ → (Tm.loc l✝).IsValue ∨ ∃ t' ρ', Tm.loc l✝ / ρ ⟶ t' / ρ'⊢ ∃ t' ρ', <{ pred ~(Tm.loc l✝) }> / ρ ⟶ t' / ρ' <;> pred.inl.abs δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextx✝:Stringτ₂✝:Tyt₁✝:Tmh:<{ ∅ / δ ⊢ λ ~x✝ : τ₂✝ . t₁✝ ⦂ Nat }>ih:∅ = ∅ → <{ λ ~x✝ : τ₂✝ . t₁✝ }>.IsValue ∨ ∃ t' ρ', <{ λ ~x✝ : τ₂✝ . t₁✝ }> / ρ ⟶ t' / ρ'⊢ ∃ t' ρ', <{ pred (λ ~x✝ : τ₂✝ . t₁✝) }> / ρ ⟶ t' / ρ'pred.inl.nat δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextn✝:Nath:<{ ∅ / δ ⊢ ~(Tm.const n✝) ⦂ Nat }>ih:∅ = ∅ → (Tm.const n✝).IsValue ∨ ∃ t' ρ', Tm.const n✝ / ρ ⟶ t' / ρ'⊢ ∃ t' ρ', <{ pred ~(Tm.const n✝) }> / ρ ⟶ t' / ρ'pred.inl.unit δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contexth:<{ ∅ / δ ⊢ unit ⦂ Nat }>ih:∅ = ∅ → <{ unit }>.IsValue ∨ ∃ t' ρ', <{ unit }> / ρ ⟶ t' / ρ'⊢ ∃ t' ρ', <{ pred unit }> / ρ ⟶ t' / ρ'pred.inl.loc_ δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextl✝:Nath:<{ ∅ / δ ⊢ ~(Tm.loc l✝) ⦂ Nat }>ih:∅ = ∅ → (Tm.loc l✝).IsValue ∨ ∃ t' ρ', Tm.loc l✝ / ρ ⟶ t' / ρ'⊢ ∃ t' ρ', <{ pred ~(Tm.loc l✝) }> / ρ ⟶ t' / ρ' try contradiction All goals completed! 🐙
apply Exists.intro pred.inl.nat.h δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextn✝:Nath:<{ ∅ / δ ⊢ ~(Tm.const n✝) ⦂ Nat }>ih:∅ = ∅ → (Tm.const n✝).IsValue ∨ ∃ t' ρ', Tm.const n✝ / ρ ⟶ t' / ρ'⊢ ∃ ρ', <{ pred ~(Tm.const n✝) }> / ρ ⟶ ?pred.inl.nat.w / ρ'pred.inl.nat.w δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextn✝:Nath:<{ ∅ / δ ⊢ ~(Tm.const n✝) ⦂ Nat }>ih:∅ = ∅ → (Tm.const n✝).IsValue ∨ ∃ t' ρ', Tm.const n✝ / ρ ⟶ t' / ρ'⊢ Tm; apply Exists.intro pred.inl.nat.h.h δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextn✝:Nath:<{ ∅ / δ ⊢ ~(Tm.const n✝) ⦂ Nat }>ih:∅ = ∅ → (Tm.const n✝).IsValue ∨ ∃ t' ρ', Tm.const n✝ / ρ ⟶ t' / ρ'⊢ <{ pred ~(Tm.const n✝) }> / ρ ⟶ ?pred.inl.nat.w / ?pred.inl.nat.h.wpred.inl.nat.h.w δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextn✝:Nath:<{ ∅ / δ ⊢ ~(Tm.const n✝) ⦂ Nat }>ih:∅ = ∅ → (Tm.const n✝).IsValue ∨ ∃ t' ρ', Tm.const n✝ / ρ ⟶ t' / ρ'⊢ Storepred.inl.nat.w δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextn✝:Nath:<{ ∅ / δ ⊢ ~(Tm.const n✝) ⦂ Nat }>ih:∅ = ∅ → (Tm.const n✝).IsValue ∨ ∃ t' ρ', Tm.const n✝ / ρ ⟶ t' / ρ'⊢ Tm; solve_by_elim using StlcRefEval All goals completed! 🐙
-- t₁ steps
| inr hs => pred.inr δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₁✝:Tmh:<{ ∅ / δ ⊢ t₁✝ ⦂ Nat }>ih:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'hs:∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'⊢ ∃ t' ρ', <{ pred t₁✝ }> / ρ ⟶ t' / ρ'succ.inr δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₁✝:Tmh:<{ ∅ / δ ⊢ t₁✝ ⦂ Nat }>ih:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'hs:∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'⊢ ∃ t' ρ', <{ succ t₁✝ }> / ρ ⟶ t' / ρ'
have ⟨t₁', ρ', hs⟩ := hs pred.inr δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₁✝:Tmh:<{ ∅ / δ ⊢ t₁✝ ⦂ Nat }>ih:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'hs✝:∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ't₁':Tmρ':Storehs:t₁✝ / ρ ⟶ t₁' / ρ'⊢ ∃ t' ρ', <{ pred t₁✝ }> / ρ ⟶ t' / ρ'
apply Exists.intro pred.inr.h δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₁✝:Tmh:<{ ∅ / δ ⊢ t₁✝ ⦂ Nat }>ih:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'hs✝:∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ't₁':Tmρ':Storehs:t₁✝ / ρ ⟶ t₁' / ρ'⊢ ∃ ρ', <{ pred t₁✝ }> / ρ ⟶ ?pred.inr.w / ρ'pred.inr.w δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₁✝:Tmh:<{ ∅ / δ ⊢ t₁✝ ⦂ Nat }>ih:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'hs✝:∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ't₁':Tmρ':Storehs:t₁✝ / ρ ⟶ t₁' / ρ'⊢ Tm; apply Exists.intro pred.inr.h.h δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₁✝:Tmh:<{ ∅ / δ ⊢ t₁✝ ⦂ Nat }>ih:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'hs✝:∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ't₁':Tmρ':Storehs:t₁✝ / ρ ⟶ t₁' / ρ'⊢ <{ pred t₁✝ }> / ρ ⟶ ?pred.inr.w / ?pred.inr.h.wpred.inr.h.w δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₁✝:Tmh:<{ ∅ / δ ⊢ t₁✝ ⦂ Nat }>ih:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'hs✝:∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ't₁':Tmρ':Storehs:t₁✝ / ρ ⟶ t₁' / ρ'⊢ Storepred.inr.w δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₁✝:Tmh:<{ ∅ / δ ⊢ t₁✝ ⦂ Nat }>ih:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'hs✝:∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ't₁':Tmρ':Storehs:t₁✝ / ρ ⟶ t₁' / ρ'⊢ Tm; solve_by_elim using StlcRefEval All goals completed! 🐙
| mult h₁ h₂ ih₁ ih₂ => mult δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₁✝:Tmt₂✝:Tmh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ Nat }>h₂:<{ ∅ / δ ⊢ t₂✝ ⦂ Nat }>ih₁:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'ih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'⊢ <{ t₁✝ * t₂✝ }>.IsValue ∨ ∃ t' ρ', <{ t₁✝ * t₂✝ }> / ρ ⟶ t' / ρ'
right mult δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₁✝:Tmt₂✝:Tmh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ Nat }>h₂:<{ ∅ / δ ⊢ t₂✝ ⦂ Nat }>ih₁:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'ih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'⊢ ∃ t' ρ', <{ t₁✝ * t₂✝ }> / ρ ⟶ t' / ρ'; cases ih₁ (by δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₁✝:Tmt₂✝:Tmh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ Nat }>h₂:<{ ∅ / δ ⊢ t₂✝ ⦂ Nat }>ih₁:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'ih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'⊢ ∅ = ∅ rfl All goals completed! 🐙) with
-- t₁ is a value
| inl hv₁ => mult.inl δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₁✝:Tmt₂✝:Tmh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ Nat }>h₂:<{ ∅ / δ ⊢ t₂✝ ⦂ Nat }>ih₁:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'ih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'hv₁:t₁✝.IsValue⊢ ∃ t' ρ', <{ t₁✝ * t₂✝ }> / ρ ⟶ t' / ρ'
cases ih₂ (by δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₁✝:Tmt₂✝:Tmh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ Nat }>h₂:<{ ∅ / δ ⊢ t₂✝ ⦂ Nat }>ih₁:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'ih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'hv₁:t₁✝.IsValue⊢ ∅ = ∅ rfl All goals completed! 🐙) with
-- t₂ is a value
| inl hv₂ => mult.inl.inl δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₁✝:Tmt₂✝:Tmh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ Nat }>h₂:<{ ∅ / δ ⊢ t₂✝ ⦂ Nat }>ih₁:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'ih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'hv₁:t₁✝.IsValuehv₂:t₂✝.IsValue⊢ ∃ t' ρ', <{ t₁✝ * t₂✝ }> / ρ ⟶ t' / ρ'
cases hv₁ mult.inl.inl.abs δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₂✝:Tmh₂:<{ ∅ / δ ⊢ t₂✝ ⦂ Nat }>ih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'hv₂:t₂✝.IsValuex✝:Stringτ₂✝:Tyt₁✝:Tmh₁:<{ ∅ / δ ⊢ λ ~x✝ : τ₂✝ . t₁✝ ⦂ Nat }>ih₁:∅ = ∅ → <{ λ ~x✝ : τ₂✝ . t₁✝ }>.IsValue ∨ ∃ t' ρ', <{ λ ~x✝ : τ₂✝ . t₁✝ }> / ρ ⟶ t' / ρ'⊢ ∃ t' ρ', <{ (λ ~x✝ : τ₂✝ . t₁✝) * t₂✝ }> / ρ ⟶ t' / ρ'mult.inl.inl.nat δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₂✝:Tmh₂:<{ ∅ / δ ⊢ t₂✝ ⦂ Nat }>ih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'hv₂:t₂✝.IsValuen✝:Nath₁:<{ ∅ / δ ⊢ ~(Tm.const n✝) ⦂ Nat }>ih₁:∅ = ∅ → (Tm.const n✝).IsValue ∨ ∃ t' ρ', Tm.const n✝ / ρ ⟶ t' / ρ'⊢ ∃ t' ρ', <{ ~(Tm.const n✝) * t₂✝ }> / ρ ⟶ t' / ρ'mult.inl.inl.unit δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₂✝:Tmh₂:<{ ∅ / δ ⊢ t₂✝ ⦂ Nat }>ih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'hv₂:t₂✝.IsValueh₁:<{ ∅ / δ ⊢ unit ⦂ Nat }>ih₁:∅ = ∅ → <{ unit }>.IsValue ∨ ∃ t' ρ', <{ unit }> / ρ ⟶ t' / ρ'⊢ ∃ t' ρ', <{ unit * t₂✝ }> / ρ ⟶ t' / ρ'mult.inl.inl.loc_ δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₂✝:Tmh₂:<{ ∅ / δ ⊢ t₂✝ ⦂ Nat }>ih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'hv₂:t₂✝.IsValuel✝:Nath₁:<{ ∅ / δ ⊢ ~(Tm.loc l✝) ⦂ Nat }>ih₁:∅ = ∅ → (Tm.loc l✝).IsValue ∨ ∃ t' ρ', Tm.loc l✝ / ρ ⟶ t' / ρ'⊢ ∃ t' ρ', <{ ~(Tm.loc l✝) * t₂✝ }> / ρ ⟶ t' / ρ' <;> mult.inl.inl.abs δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₂✝:Tmh₂:<{ ∅ / δ ⊢ t₂✝ ⦂ Nat }>ih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'hv₂:t₂✝.IsValuex✝:Stringτ₂✝:Tyt₁✝:Tmh₁:<{ ∅ / δ ⊢ λ ~x✝ : τ₂✝ . t₁✝ ⦂ Nat }>ih₁:∅ = ∅ → <{ λ ~x✝ : τ₂✝ . t₁✝ }>.IsValue ∨ ∃ t' ρ', <{ λ ~x✝ : τ₂✝ . t₁✝ }> / ρ ⟶ t' / ρ'⊢ ∃ t' ρ', <{ (λ ~x✝ : τ₂✝ . t₁✝) * t₂✝ }> / ρ ⟶ t' / ρ'mult.inl.inl.nat δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₂✝:Tmh₂:<{ ∅ / δ ⊢ t₂✝ ⦂ Nat }>ih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'hv₂:t₂✝.IsValuen✝:Nath₁:<{ ∅ / δ ⊢ ~(Tm.const n✝) ⦂ Nat }>ih₁:∅ = ∅ → (Tm.const n✝).IsValue ∨ ∃ t' ρ', Tm.const n✝ / ρ ⟶ t' / ρ'⊢ ∃ t' ρ', <{ ~(Tm.const n✝) * t₂✝ }> / ρ ⟶ t' / ρ'mult.inl.inl.unit δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₂✝:Tmh₂:<{ ∅ / δ ⊢ t₂✝ ⦂ Nat }>ih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'hv₂:t₂✝.IsValueh₁:<{ ∅ / δ ⊢ unit ⦂ Nat }>ih₁:∅ = ∅ → <{ unit }>.IsValue ∨ ∃ t' ρ', <{ unit }> / ρ ⟶ t' / ρ'⊢ ∃ t' ρ', <{ unit * t₂✝ }> / ρ ⟶ t' / ρ'mult.inl.inl.loc_ δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₂✝:Tmh₂:<{ ∅ / δ ⊢ t₂✝ ⦂ Nat }>ih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'hv₂:t₂✝.IsValuel✝:Nath₁:<{ ∅ / δ ⊢ ~(Tm.loc l✝) ⦂ Nat }>ih₁:∅ = ∅ → (Tm.loc l✝).IsValue ∨ ∃ t' ρ', Tm.loc l✝ / ρ ⟶ t' / ρ'⊢ ∃ t' ρ', <{ ~(Tm.loc l✝) * t₂✝ }> / ρ ⟶ t' / ρ' try contradiction All goals completed! 🐙
cases hv₂ mult.inl.inl.nat.abs δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextn✝:Nath₁:<{ ∅ / δ ⊢ ~(Tm.const n✝) ⦂ Nat }>ih₁:∅ = ∅ → (Tm.const n✝).IsValue ∨ ∃ t' ρ', Tm.const n✝ / ρ ⟶ t' / ρ'x✝:Stringτ₂✝:Tyt₁✝:Tmh₂:<{ ∅ / δ ⊢ λ ~x✝ : τ₂✝ . t₁✝ ⦂ Nat }>ih₂:∅ = ∅ → <{ λ ~x✝ : τ₂✝ . t₁✝ }>.IsValue ∨ ∃ t' ρ', <{ λ ~x✝ : τ₂✝ . t₁✝ }> / ρ ⟶ t' / ρ'⊢ ∃ t' ρ', <{ ~(Tm.const n✝) * (λ ~x✝ : τ₂✝ . t₁✝) }> / ρ ⟶ t' / ρ'mult.inl.inl.nat.nat δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextn✝¹:Nath₁:<{ ∅ / δ ⊢ ~(Tm.const n✝) ⦂ Nat }>ih₁:∅ = ∅ → (Tm.const n✝).IsValue ∨ ∃ t' ρ', Tm.const n✝ / ρ ⟶ t' / ρ'n✝:Nath₂:<{ ∅ / δ ⊢ ~(Tm.const n✝) ⦂ Nat }>ih₂:∅ = ∅ → (Tm.const n✝).IsValue ∨ ∃ t' ρ', Tm.const n✝ / ρ ⟶ t' / ρ'⊢ ∃ t' ρ', <{ ~(Tm.const n✝¹) * ~(Tm.const n✝) }> / ρ ⟶ t' / ρ'mult.inl.inl.nat.unit δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextn✝:Nath₁:<{ ∅ / δ ⊢ ~(Tm.const n✝) ⦂ Nat }>ih₁:∅ = ∅ → (Tm.const n✝).IsValue ∨ ∃ t' ρ', Tm.const n✝ / ρ ⟶ t' / ρ'h₂:<{ ∅ / δ ⊢ unit ⦂ Nat }>ih₂:∅ = ∅ → <{ unit }>.IsValue ∨ ∃ t' ρ', <{ unit }> / ρ ⟶ t' / ρ'⊢ ∃ t' ρ', <{ ~(Tm.const n✝) * unit }> / ρ ⟶ t' / ρ'mult.inl.inl.nat.loc_ δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextn✝:Nath₁:<{ ∅ / δ ⊢ ~(Tm.const n✝) ⦂ Nat }>ih₁:∅ = ∅ → (Tm.const n✝).IsValue ∨ ∃ t' ρ', Tm.const n✝ / ρ ⟶ t' / ρ'l✝:Nath₂:<{ ∅ / δ ⊢ ~(Tm.loc l✝) ⦂ Nat }>ih₂:∅ = ∅ → (Tm.loc l✝).IsValue ∨ ∃ t' ρ', Tm.loc l✝ / ρ ⟶ t' / ρ'⊢ ∃ t' ρ', <{ ~(Tm.const n✝) * ~(Tm.loc l✝) }> / ρ ⟶ t' / ρ' <;> mult.inl.inl.nat.abs δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextn✝:Nath₁:<{ ∅ / δ ⊢ ~(Tm.const n✝) ⦂ Nat }>ih₁:∅ = ∅ → (Tm.const n✝).IsValue ∨ ∃ t' ρ', Tm.const n✝ / ρ ⟶ t' / ρ'x✝:Stringτ₂✝:Tyt₁✝:Tmh₂:<{ ∅ / δ ⊢ λ ~x✝ : τ₂✝ . t₁✝ ⦂ Nat }>ih₂:∅ = ∅ → <{ λ ~x✝ : τ₂✝ . t₁✝ }>.IsValue ∨ ∃ t' ρ', <{ λ ~x✝ : τ₂✝ . t₁✝ }> / ρ ⟶ t' / ρ'⊢ ∃ t' ρ', <{ ~(Tm.const n✝) * (λ ~x✝ : τ₂✝ . t₁✝) }> / ρ ⟶ t' / ρ'mult.inl.inl.nat.nat δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextn✝¹:Nath₁:<{ ∅ / δ ⊢ ~(Tm.const n✝) ⦂ Nat }>ih₁:∅ = ∅ → (Tm.const n✝).IsValue ∨ ∃ t' ρ', Tm.const n✝ / ρ ⟶ t' / ρ'n✝:Nath₂:<{ ∅ / δ ⊢ ~(Tm.const n✝) ⦂ Nat }>ih₂:∅ = ∅ → (Tm.const n✝).IsValue ∨ ∃ t' ρ', Tm.const n✝ / ρ ⟶ t' / ρ'⊢ ∃ t' ρ', <{ ~(Tm.const n✝¹) * ~(Tm.const n✝) }> / ρ ⟶ t' / ρ'mult.inl.inl.nat.unit δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextn✝:Nath₁:<{ ∅ / δ ⊢ ~(Tm.const n✝) ⦂ Nat }>ih₁:∅ = ∅ → (Tm.const n✝).IsValue ∨ ∃ t' ρ', Tm.const n✝ / ρ ⟶ t' / ρ'h₂:<{ ∅ / δ ⊢ unit ⦂ Nat }>ih₂:∅ = ∅ → <{ unit }>.IsValue ∨ ∃ t' ρ', <{ unit }> / ρ ⟶ t' / ρ'⊢ ∃ t' ρ', <{ ~(Tm.const n✝) * unit }> / ρ ⟶ t' / ρ'mult.inl.inl.nat.loc_ δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextn✝:Nath₁:<{ ∅ / δ ⊢ ~(Tm.const n✝) ⦂ Nat }>ih₁:∅ = ∅ → (Tm.const n✝).IsValue ∨ ∃ t' ρ', Tm.const n✝ / ρ ⟶ t' / ρ'l✝:Nath₂:<{ ∅ / δ ⊢ ~(Tm.loc l✝) ⦂ Nat }>ih₂:∅ = ∅ → (Tm.loc l✝).IsValue ∨ ∃ t' ρ', Tm.loc l✝ / ρ ⟶ t' / ρ'⊢ ∃ t' ρ', <{ ~(Tm.const n✝) * ~(Tm.loc l✝) }> / ρ ⟶ t' / ρ' try contradiction All goals completed! 🐙
apply Exists.intro mult.inl.inl.nat.nat.h δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextn✝¹:Nath₁:<{ ∅ / δ ⊢ ~(Tm.const n✝) ⦂ Nat }>ih₁:∅ = ∅ → (Tm.const n✝).IsValue ∨ ∃ t' ρ', Tm.const n✝ / ρ ⟶ t' / ρ'n✝:Nath₂:<{ ∅ / δ ⊢ ~(Tm.const n✝) ⦂ Nat }>ih₂:∅ = ∅ → (Tm.const n✝).IsValue ∨ ∃ t' ρ', Tm.const n✝ / ρ ⟶ t' / ρ'⊢ ∃ ρ', <{ ~(Tm.const n✝¹) * ~(Tm.const n✝) }> / ρ ⟶ ?mult.inl.inl.nat.nat.w / ρ'mult.inl.inl.nat.nat.w δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextn✝¹:Nath₁:<{ ∅ / δ ⊢ ~(Tm.const n✝) ⦂ Nat }>ih₁:∅ = ∅ → (Tm.const n✝).IsValue ∨ ∃ t' ρ', Tm.const n✝ / ρ ⟶ t' / ρ'n✝:Nath₂:<{ ∅ / δ ⊢ ~(Tm.const n✝) ⦂ Nat }>ih₂:∅ = ∅ → (Tm.const n✝).IsValue ∨ ∃ t' ρ', Tm.const n✝ / ρ ⟶ t' / ρ'⊢ Tm; apply Exists.intro mult.inl.inl.nat.nat.h.h δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextn✝¹:Nath₁:<{ ∅ / δ ⊢ ~(Tm.const n✝) ⦂ Nat }>ih₁:∅ = ∅ → (Tm.const n✝).IsValue ∨ ∃ t' ρ', Tm.const n✝ / ρ ⟶ t' / ρ'n✝:Nath₂:<{ ∅ / δ ⊢ ~(Tm.const n✝) ⦂ Nat }>ih₂:∅ = ∅ → (Tm.const n✝).IsValue ∨ ∃ t' ρ', Tm.const n✝ / ρ ⟶ t' / ρ'⊢ <{ ~(Tm.const n✝¹) * ~(Tm.const n✝) }> / ρ ⟶ ?mult.inl.inl.nat.nat.w / ?mult.inl.inl.nat.nat.h.wmult.inl.inl.nat.nat.h.w δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextn✝¹:Nath₁:<{ ∅ / δ ⊢ ~(Tm.const n✝) ⦂ Nat }>ih₁:∅ = ∅ → (Tm.const n✝).IsValue ∨ ∃ t' ρ', Tm.const n✝ / ρ ⟶ t' / ρ'n✝:Nath₂:<{ ∅ / δ ⊢ ~(Tm.const n✝) ⦂ Nat }>ih₂:∅ = ∅ → (Tm.const n✝).IsValue ∨ ∃ t' ρ', Tm.const n✝ / ρ ⟶ t' / ρ'⊢ Storemult.inl.inl.nat.nat.w δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextn✝¹:Nath₁:<{ ∅ / δ ⊢ ~(Tm.const n✝) ⦂ Nat }>ih₁:∅ = ∅ → (Tm.const n✝).IsValue ∨ ∃ t' ρ', Tm.const n✝ / ρ ⟶ t' / ρ'n✝:Nath₂:<{ ∅ / δ ⊢ ~(Tm.const n✝) ⦂ Nat }>ih₂:∅ = ∅ → (Tm.const n✝).IsValue ∨ ∃ t' ρ', Tm.const n✝ / ρ ⟶ t' / ρ'⊢ Tm; solve_by_elim using StlcRefEval All goals completed! 🐙
-- t₂ steps
| inr hs₂ => mult.inl.inr δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₁✝:Tmt₂✝:Tmh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ Nat }>h₂:<{ ∅ / δ ⊢ t₂✝ ⦂ Nat }>ih₁:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'ih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'hv₁:t₁✝.IsValuehs₂:∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'⊢ ∃ t' ρ', <{ t₁✝ * t₂✝ }> / ρ ⟶ t' / ρ'
have ⟨t₂', ρ', hs₂⟩ := hs₂ mult.inl.inr δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₁✝:Tmt₂✝:Tmh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ Nat }>h₂:<{ ∅ / δ ⊢ t₂✝ ⦂ Nat }>ih₁:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'ih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'hv₁:t₁✝.IsValuehs₂✝:∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ't₂':Tmρ':Storehs₂:t₂✝ / ρ ⟶ t₂' / ρ'⊢ ∃ t' ρ', <{ t₁✝ * t₂✝ }> / ρ ⟶ t' / ρ'
apply Exists.intro mult.inl.inr.h δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₁✝:Tmt₂✝:Tmh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ Nat }>h₂:<{ ∅ / δ ⊢ t₂✝ ⦂ Nat }>ih₁:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'ih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'hv₁:t₁✝.IsValuehs₂✝:∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ't₂':Tmρ':Storehs₂:t₂✝ / ρ ⟶ t₂' / ρ'⊢ ∃ ρ', <{ t₁✝ * t₂✝ }> / ρ ⟶ ?mult.inl.inr.w / ρ'mult.inl.inr.w δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₁✝:Tmt₂✝:Tmh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ Nat }>h₂:<{ ∅ / δ ⊢ t₂✝ ⦂ Nat }>ih₁:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'ih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'hv₁:t₁✝.IsValuehs₂✝:∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ't₂':Tmρ':Storehs₂:t₂✝ / ρ ⟶ t₂' / ρ'⊢ Tm; apply Exists.intro mult.inl.inr.h.h δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₁✝:Tmt₂✝:Tmh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ Nat }>h₂:<{ ∅ / δ ⊢ t₂✝ ⦂ Nat }>ih₁:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'ih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'hv₁:t₁✝.IsValuehs₂✝:∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ't₂':Tmρ':Storehs₂:t₂✝ / ρ ⟶ t₂' / ρ'⊢ <{ t₁✝ * t₂✝ }> / ρ ⟶ ?mult.inl.inr.w / ?mult.inl.inr.h.wmult.inl.inr.h.w δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₁✝:Tmt₂✝:Tmh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ Nat }>h₂:<{ ∅ / δ ⊢ t₂✝ ⦂ Nat }>ih₁:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'ih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'hv₁:t₁✝.IsValuehs₂✝:∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ't₂':Tmρ':Storehs₂:t₂✝ / ρ ⟶ t₂' / ρ'⊢ Storemult.inl.inr.w δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₁✝:Tmt₂✝:Tmh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ Nat }>h₂:<{ ∅ / δ ⊢ t₂✝ ⦂ Nat }>ih₁:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'ih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'hv₁:t₁✝.IsValuehs₂✝:∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ't₂':Tmρ':Storehs₂:t₂✝ / ρ ⟶ t₂' / ρ'⊢ Tm; solve_by_elim using StlcRefEval All goals completed! 🐙
-- t₁ steps
| inr hs₁ => mult.inr δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₁✝:Tmt₂✝:Tmh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ Nat }>h₂:<{ ∅ / δ ⊢ t₂✝ ⦂ Nat }>ih₁:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'ih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'hs₁:∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'⊢ ∃ t' ρ', <{ t₁✝ * t₂✝ }> / ρ ⟶ t' / ρ'
have ⟨t₁', ρ', hs₁⟩ := hs₁ mult.inr δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₁✝:Tmt₂✝:Tmh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ Nat }>h₂:<{ ∅ / δ ⊢ t₂✝ ⦂ Nat }>ih₁:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'ih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'hs₁✝:∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ't₁':Tmρ':Storehs₁:t₁✝ / ρ ⟶ t₁' / ρ'⊢ ∃ t' ρ', <{ t₁✝ * t₂✝ }> / ρ ⟶ t' / ρ'
apply Exists.intro mult.inr.h δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₁✝:Tmt₂✝:Tmh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ Nat }>h₂:<{ ∅ / δ ⊢ t₂✝ ⦂ Nat }>ih₁:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'ih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'hs₁✝:∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ't₁':Tmρ':Storehs₁:t₁✝ / ρ ⟶ t₁' / ρ'⊢ ∃ ρ', <{ t₁✝ * t₂✝ }> / ρ ⟶ ?mult.inr.w / ρ'mult.inr.w δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₁✝:Tmt₂✝:Tmh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ Nat }>h₂:<{ ∅ / δ ⊢ t₂✝ ⦂ Nat }>ih₁:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'ih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'hs₁✝:∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ't₁':Tmρ':Storehs₁:t₁✝ / ρ ⟶ t₁' / ρ'⊢ Tm; apply Exists.intro mult.inr.h.h δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₁✝:Tmt₂✝:Tmh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ Nat }>h₂:<{ ∅ / δ ⊢ t₂✝ ⦂ Nat }>ih₁:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'ih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'hs₁✝:∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ't₁':Tmρ':Storehs₁:t₁✝ / ρ ⟶ t₁' / ρ'⊢ <{ t₁✝ * t₂✝ }> / ρ ⟶ ?mult.inr.w / ?mult.inr.h.wmult.inr.h.w δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₁✝:Tmt₂✝:Tmh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ Nat }>h₂:<{ ∅ / δ ⊢ t₂✝ ⦂ Nat }>ih₁:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'ih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'hs₁✝:∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ't₁':Tmρ':Storehs₁:t₁✝ / ρ ⟶ t₁' / ρ'⊢ Storemult.inr.w δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₁✝:Tmt₂✝:Tmh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ Nat }>h₂:<{ ∅ / δ ⊢ t₂✝ ⦂ Nat }>ih₁:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'ih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'hs₁✝:∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ't₁':Tmρ':Storehs₁:t₁✝ / ρ ⟶ t₁' / ρ'⊢ Tm; solve_by_elim using StlcRefEval All goals completed! 🐙
| ite0 h₁ _ _ ih₁ _ _ => ite0 δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₁✝:Tmt₂✝:Tmt₃✝:Tmτ✝:Tyh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ Nat }>h₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ τ✝ }>h₃✝:<{ ∅ / δ ⊢ t₃✝ ⦂ τ✝ }>ih₁:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'h₂_ih✝:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'h₃_ih✝:∅ = ∅ → t₃✝.IsValue ∨ ∃ t' ρ', t₃✝ / ρ ⟶ t' / ρ'⊢ <{ if0 t₁✝ then t₂✝ else t₃✝ }>.IsValue ∨ ∃ t' ρ', <{ if0 t₁✝ then t₂✝ else t₃✝ }> / ρ ⟶ t' / ρ'
right ite0 δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₁✝:Tmt₂✝:Tmt₃✝:Tmτ✝:Tyh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ Nat }>h₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ τ✝ }>h₃✝:<{ ∅ / δ ⊢ t₃✝ ⦂ τ✝ }>ih₁:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'h₂_ih✝:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'h₃_ih✝:∅ = ∅ → t₃✝.IsValue ∨ ∃ t' ρ', t₃✝ / ρ ⟶ t' / ρ'⊢ ∃ t' ρ', <{ if0 t₁✝ then t₂✝ else t₃✝ }> / ρ ⟶ t' / ρ'; cases ih₁ (by δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₁✝:Tmt₂✝:Tmt₃✝:Tmτ✝:Tyh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ Nat }>h₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ τ✝ }>h₃✝:<{ ∅ / δ ⊢ t₃✝ ⦂ τ✝ }>ih₁:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'h₂_ih✝:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'h₃_ih✝:∅ = ∅ → t₃✝.IsValue ∨ ∃ t' ρ', t₃✝ / ρ ⟶ t' / ρ'⊢ ∅ = ∅ rfl All goals completed! 🐙) with
-- t₁ is a value
| inl hv₁ => ite0.inl δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₁✝:Tmt₂✝:Tmt₃✝:Tmτ✝:Tyh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ Nat }>h₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ τ✝ }>h₃✝:<{ ∅ / δ ⊢ t₃✝ ⦂ τ✝ }>ih₁:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'h₂_ih✝:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'h₃_ih✝:∅ = ∅ → t₃✝.IsValue ∨ ∃ t' ρ', t₃✝ / ρ ⟶ t' / ρ'hv₁:t₁✝.IsValue⊢ ∃ t' ρ', <{ if0 t₁✝ then t₂✝ else t₃✝ }> / ρ ⟶ t' / ρ'
cases hv₁ with (try contradiction All goals completed! 🐙)
| nat n => ite0.inl.nat δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₂✝:Tmt₃✝:Tmτ✝:Tyh₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ τ✝ }>h₃✝:<{ ∅ / δ ⊢ t₃✝ ⦂ τ✝ }>h₂_ih✝:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'h₃_ih✝:∅ = ∅ → t₃✝.IsValue ∨ ∃ t' ρ', t₃✝ / ρ ⟶ t' / ρ'n:Nath₁:<{ ∅ / δ ⊢ ~(Tm.const n) ⦂ Nat }>ih₁:∅ = ∅ → (Tm.const n).IsValue ∨ ∃ t' ρ', Tm.const n / ρ ⟶ t' / ρ'⊢ ∃ t' ρ', <{ if0 ~(Tm.const n) then t₂✝ else t₃✝ }> / ρ ⟶ t' / ρ'
cases n ite0.inl.nat.zero δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₂✝:Tmt₃✝:Tmτ✝:Tyh₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ τ✝ }>h₃✝:<{ ∅ / δ ⊢ t₃✝ ⦂ τ✝ }>h₂_ih✝:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'h₃_ih✝:∅ = ∅ → t₃✝.IsValue ∨ ∃ t' ρ', t₃✝ / ρ ⟶ t' / ρ'h₁:<{ ∅ / δ ⊢ 0 ⦂ Nat }>ih₁:∅ = ∅ → <{ 0 }>.IsValue ∨ ∃ t' ρ', <{ 0 }> / ρ ⟶ t' / ρ'⊢ ∃ t' ρ', <{ if0 0 then t₂✝ else t₃✝ }> / ρ ⟶ t' / ρ'ite0.inl.nat.succ δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₂✝:Tmt₃✝:Tmτ✝:Tyh₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ τ✝ }>h₃✝:<{ ∅ / δ ⊢ t₃✝ ⦂ τ✝ }>h₂_ih✝:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'h₃_ih✝:∅ = ∅ → t₃✝.IsValue ∨ ∃ t' ρ', t₃✝ / ρ ⟶ t' / ρ'n✝:Nath₁:<{ ∅ / δ ⊢ ~(Tm.const (n✝ + 1)) ⦂ Nat }>ih₁:∅ = ∅ → (Tm.const (n✝ + 1)).IsValue ∨ ∃ t' ρ', Tm.const (n✝ + 1) / ρ ⟶ t' / ρ'⊢ ∃ t' ρ', <{ if0 ~(Tm.const (n✝ + 1)) then t₂✝ else t₃✝ }> / ρ ⟶ t' / ρ' <;> ite0.inl.nat.zero δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₂✝:Tmt₃✝:Tmτ✝:Tyh₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ τ✝ }>h₃✝:<{ ∅ / δ ⊢ t₃✝ ⦂ τ✝ }>h₂_ih✝:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'h₃_ih✝:∅ = ∅ → t₃✝.IsValue ∨ ∃ t' ρ', t₃✝ / ρ ⟶ t' / ρ'h₁:<{ ∅ / δ ⊢ 0 ⦂ Nat }>ih₁:∅ = ∅ → <{ 0 }>.IsValue ∨ ∃ t' ρ', <{ 0 }> / ρ ⟶ t' / ρ'⊢ ∃ t' ρ', <{ if0 0 then t₂✝ else t₃✝ }> / ρ ⟶ t' / ρ'ite0.inl.nat.succ δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₂✝:Tmt₃✝:Tmτ✝:Tyh₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ τ✝ }>h₃✝:<{ ∅ / δ ⊢ t₃✝ ⦂ τ✝ }>h₂_ih✝:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'h₃_ih✝:∅ = ∅ → t₃✝.IsValue ∨ ∃ t' ρ', t₃✝ / ρ ⟶ t' / ρ'n✝:Nath₁:<{ ∅ / δ ⊢ ~(Tm.const (n✝ + 1)) ⦂ Nat }>ih₁:∅ = ∅ → (Tm.const (n✝ + 1)).IsValue ∨ ∃ t' ρ', Tm.const (n✝ + 1) / ρ ⟶ t' / ρ'⊢ ∃ t' ρ', <{ if0 ~(Tm.const (n✝ + 1)) then t₂✝ else t₃✝ }> / ρ ⟶ t' / ρ' (apply Exists.intro ite0.inl.nat.succ.h δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₂✝:Tmt₃✝:Tmτ✝:Tyh₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ τ✝ }>h₃✝:<{ ∅ / δ ⊢ t₃✝ ⦂ τ✝ }>h₂_ih✝:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'h₃_ih✝:∅ = ∅ → t₃✝.IsValue ∨ ∃ t' ρ', t₃✝ / ρ ⟶ t' / ρ'n✝:Nath₁:<{ ∅ / δ ⊢ ~(Tm.const (n✝ + 1)) ⦂ Nat }>ih₁:∅ = ∅ → (Tm.const (n✝ + 1)).IsValue ∨ ∃ t' ρ', Tm.const (n✝ + 1) / ρ ⟶ t' / ρ'⊢ ∃ ρ', <{ if0 ~(Tm.const (n✝ + 1)) then t₂✝ else t₃✝ }> / ρ ⟶ ?ite0.inl.nat.succ.w / ρ'ite0.inl.nat.succ.w δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₂✝:Tmt₃✝:Tmτ✝:Tyh₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ τ✝ }>h₃✝:<{ ∅ / δ ⊢ t₃✝ ⦂ τ✝ }>h₂_ih✝:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'h₃_ih✝:∅ = ∅ → t₃✝.IsValue ∨ ∃ t' ρ', t₃✝ / ρ ⟶ t' / ρ'n✝:Nath₁:<{ ∅ / δ ⊢ ~(Tm.const (n✝ + 1)) ⦂ Nat }>ih₁:∅ = ∅ → (Tm.const (n✝ + 1)).IsValue ∨ ∃ t' ρ', Tm.const (n✝ + 1) / ρ ⟶ t' / ρ'⊢ Tm; apply Exists.intro ite0.inl.nat.succ.h.h δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₂✝:Tmt₃✝:Tmτ✝:Tyh₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ τ✝ }>h₃✝:<{ ∅ / δ ⊢ t₃✝ ⦂ τ✝ }>h₂_ih✝:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'h₃_ih✝:∅ = ∅ → t₃✝.IsValue ∨ ∃ t' ρ', t₃✝ / ρ ⟶ t' / ρ'n✝:Nath₁:<{ ∅ / δ ⊢ ~(Tm.const (n✝ + 1)) ⦂ Nat }>ih₁:∅ = ∅ → (Tm.const (n✝ + 1)).IsValue ∨ ∃ t' ρ', Tm.const (n✝ + 1) / ρ ⟶ t' / ρ'⊢ <{ if0 ~(Tm.const (n✝ + 1)) then t₂✝ else t₃✝ }> / ρ ⟶ ?ite0.inl.nat.succ.w / ?ite0.inl.nat.succ.h.wite0.inl.nat.succ.h.w δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₂✝:Tmt₃✝:Tmτ✝:Tyh₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ τ✝ }>h₃✝:<{ ∅ / δ ⊢ t₃✝ ⦂ τ✝ }>h₂_ih✝:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'h₃_ih✝:∅ = ∅ → t₃✝.IsValue ∨ ∃ t' ρ', t₃✝ / ρ ⟶ t' / ρ'n✝:Nath₁:<{ ∅ / δ ⊢ ~(Tm.const (n✝ + 1)) ⦂ Nat }>ih₁:∅ = ∅ → (Tm.const (n✝ + 1)).IsValue ∨ ∃ t' ρ', Tm.const (n✝ + 1) / ρ ⟶ t' / ρ'⊢ Storeite0.inl.nat.succ.w δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₂✝:Tmt₃✝:Tmτ✝:Tyh₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ τ✝ }>h₃✝:<{ ∅ / δ ⊢ t₃✝ ⦂ τ✝ }>h₂_ih✝:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'h₃_ih✝:∅ = ∅ → t₃✝.IsValue ∨ ∃ t' ρ', t₃✝ / ρ ⟶ t' / ρ'n✝:Nath₁:<{ ∅ / δ ⊢ ~(Tm.const (n✝ + 1)) ⦂ Nat }>ih₁:∅ = ∅ → (Tm.const (n✝ + 1)).IsValue ∨ ∃ t' ρ', Tm.const (n✝ + 1) / ρ ⟶ t' / ρ'⊢ Tm; solve_by_elim using StlcRefEval All goals completed! 🐙)
-- t₁ steps
| inr hs₁ => ite0.inr δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₁✝:Tmt₂✝:Tmt₃✝:Tmτ✝:Tyh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ Nat }>h₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ τ✝ }>h₃✝:<{ ∅ / δ ⊢ t₃✝ ⦂ τ✝ }>ih₁:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'h₂_ih✝:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'h₃_ih✝:∅ = ∅ → t₃✝.IsValue ∨ ∃ t' ρ', t₃✝ / ρ ⟶ t' / ρ'hs₁:∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'⊢ ∃ t' ρ', <{ if0 t₁✝ then t₂✝ else t₃✝ }> / ρ ⟶ t' / ρ'
have ⟨t₁', ρ', hs₁⟩ := hs₁ ite0.inr δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₁✝:Tmt₂✝:Tmt₃✝:Tmτ✝:Tyh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ Nat }>h₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ τ✝ }>h₃✝:<{ ∅ / δ ⊢ t₃✝ ⦂ τ✝ }>ih₁:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'h₂_ih✝:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'h₃_ih✝:∅ = ∅ → t₃✝.IsValue ∨ ∃ t' ρ', t₃✝ / ρ ⟶ t' / ρ'hs₁✝:∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ't₁':Tmρ':Storehs₁:t₁✝ / ρ ⟶ t₁' / ρ'⊢ ∃ t' ρ', <{ if0 t₁✝ then t₂✝ else t₃✝ }> / ρ ⟶ t' / ρ'
apply Exists.intro ite0.inr.h δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₁✝:Tmt₂✝:Tmt₃✝:Tmτ✝:Tyh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ Nat }>h₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ τ✝ }>h₃✝:<{ ∅ / δ ⊢ t₃✝ ⦂ τ✝ }>ih₁:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'h₂_ih✝:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'h₃_ih✝:∅ = ∅ → t₃✝.IsValue ∨ ∃ t' ρ', t₃✝ / ρ ⟶ t' / ρ'hs₁✝:∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ't₁':Tmρ':Storehs₁:t₁✝ / ρ ⟶ t₁' / ρ'⊢ ∃ ρ', <{ if0 t₁✝ then t₂✝ else t₃✝ }> / ρ ⟶ ?ite0.inr.w / ρ'ite0.inr.w δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₁✝:Tmt₂✝:Tmt₃✝:Tmτ✝:Tyh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ Nat }>h₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ τ✝ }>h₃✝:<{ ∅ / δ ⊢ t₃✝ ⦂ τ✝ }>ih₁:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'h₂_ih✝:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'h₃_ih✝:∅ = ∅ → t₃✝.IsValue ∨ ∃ t' ρ', t₃✝ / ρ ⟶ t' / ρ'hs₁✝:∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ't₁':Tmρ':Storehs₁:t₁✝ / ρ ⟶ t₁' / ρ'⊢ Tm; apply Exists.intro ite0.inr.h.h δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₁✝:Tmt₂✝:Tmt₃✝:Tmτ✝:Tyh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ Nat }>h₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ τ✝ }>h₃✝:<{ ∅ / δ ⊢ t₃✝ ⦂ τ✝ }>ih₁:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'h₂_ih✝:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'h₃_ih✝:∅ = ∅ → t₃✝.IsValue ∨ ∃ t' ρ', t₃✝ / ρ ⟶ t' / ρ'hs₁✝:∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ't₁':Tmρ':Storehs₁:t₁✝ / ρ ⟶ t₁' / ρ'⊢ <{ if0 t₁✝ then t₂✝ else t₃✝ }> / ρ ⟶ ?ite0.inr.w / ?ite0.inr.h.wite0.inr.h.w δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₁✝:Tmt₂✝:Tmt₃✝:Tmτ✝:Tyh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ Nat }>h₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ τ✝ }>h₃✝:<{ ∅ / δ ⊢ t₃✝ ⦂ τ✝ }>ih₁:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'h₂_ih✝:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'h₃_ih✝:∅ = ∅ → t₃✝.IsValue ∨ ∃ t' ρ', t₃✝ / ρ ⟶ t' / ρ'hs₁✝:∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ't₁':Tmρ':Storehs₁:t₁✝ / ρ ⟶ t₁' / ρ'⊢ Storeite0.inr.w δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₁✝:Tmt₂✝:Tmt₃✝:Tmτ✝:Tyh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ Nat }>h₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ τ✝ }>h₃✝:<{ ∅ / δ ⊢ t₃✝ ⦂ τ✝ }>ih₁:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'h₂_ih✝:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'h₃_ih✝:∅ = ∅ → t₃✝.IsValue ∨ ∃ t' ρ', t₃✝ / ρ ⟶ t' / ρ'hs₁✝:∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ't₁':Tmρ':Storehs₁:t₁✝ / ρ ⟶ t₁' / ρ'⊢ Tm; solve_by_elim using StlcRefEval All goals completed! 🐙
| ref_ _ ih => ref_ δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₁✝:Tmτ₁✝:Tyh✝:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₁✝ }>ih:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'⊢ <{ ref t₁✝ }>.IsValue ∨ ∃ t' ρ', <{ ref t₁✝ }> / ρ ⟶ t' / ρ'
right ref_ δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₁✝:Tmτ₁✝:Tyh✝:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₁✝ }>ih:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'⊢ ∃ t' ρ', <{ ref t₁✝ }> / ρ ⟶ t' / ρ'; cases ih (by δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₁✝:Tmτ₁✝:Tyh✝:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₁✝ }>ih:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'⊢ ∅ = ∅ rfl All goals completed! 🐙) with
-- t₁ is a value
| inl hv => ref_.inl δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₁✝:Tmτ₁✝:Tyh✝:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₁✝ }>ih:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'hv:t₁✝.IsValue⊢ ∃ t' ρ', <{ ref t₁✝ }> / ρ ⟶ t' / ρ'
apply Exists.intro ref_.inl.h δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₁✝:Tmτ₁✝:Tyh✝:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₁✝ }>ih:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'hv:t₁✝.IsValue⊢ ∃ ρ', <{ ref t₁✝ }> / ρ ⟶ ?ref_.inl.w / ρ'ref_.inl.w δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₁✝:Tmτ₁✝:Tyh✝:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₁✝ }>ih:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'hv:t₁✝.IsValue⊢ Tm; apply Exists.intro ref_.inl.h.h δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₁✝:Tmτ₁✝:Tyh✝:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₁✝ }>ih:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'hv:t₁✝.IsValue⊢ <{ ref t₁✝ }> / ρ ⟶ ?ref_.inl.w / ?ref_.inl.h.wref_.inl.h.w δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₁✝:Tmτ₁✝:Tyh✝:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₁✝ }>ih:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'hv:t₁✝.IsValue⊢ Storeref_.inl.w δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₁✝:Tmτ₁✝:Tyh✝:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₁✝ }>ih:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'hv:t₁✝.IsValue⊢ Tm; solve_by_elim using StlcRefEval All goals completed! 🐙
-- t₁ steps
| inr hs => ref_.inr δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₁✝:Tmτ₁✝:Tyh✝:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₁✝ }>ih:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'hs:∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'⊢ ∃ t' ρ', <{ ref t₁✝ }> / ρ ⟶ t' / ρ'
have ⟨t₁', ρ', hs⟩ := hs ref_.inr δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₁✝:Tmτ₁✝:Tyh✝:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₁✝ }>ih:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'hs✝:∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ't₁':Tmρ':Storehs:t₁✝ / ρ ⟶ t₁' / ρ'⊢ ∃ t' ρ', <{ ref t₁✝ }> / ρ ⟶ t' / ρ'
apply Exists.intro ref_.inr.h δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₁✝:Tmτ₁✝:Tyh✝:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₁✝ }>ih:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'hs✝:∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ't₁':Tmρ':Storehs:t₁✝ / ρ ⟶ t₁' / ρ'⊢ ∃ ρ', <{ ref t₁✝ }> / ρ ⟶ ?ref_.inr.w / ρ'ref_.inr.w δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₁✝:Tmτ₁✝:Tyh✝:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₁✝ }>ih:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'hs✝:∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ't₁':Tmρ':Storehs:t₁✝ / ρ ⟶ t₁' / ρ'⊢ Tm; apply Exists.intro ref_.inr.h.h δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₁✝:Tmτ₁✝:Tyh✝:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₁✝ }>ih:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'hs✝:∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ't₁':Tmρ':Storehs:t₁✝ / ρ ⟶ t₁' / ρ'⊢ <{ ref t₁✝ }> / ρ ⟶ ?ref_.inr.w / ?ref_.inr.h.wref_.inr.h.w δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₁✝:Tmτ₁✝:Tyh✝:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₁✝ }>ih:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'hs✝:∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ't₁':Tmρ':Storehs:t₁✝ / ρ ⟶ t₁' / ρ'⊢ Storeref_.inr.w δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₁✝:Tmτ₁✝:Tyh✝:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₁✝ }>ih:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'hs✝:∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ't₁':Tmρ':Storehs:t₁✝ / ρ ⟶ t₁' / ρ'⊢ Tm; solve_by_elim using StlcRefEval All goals completed! 🐙
| deref h ih => deref δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₁✝:Tmτ₁✝:Tyh:<{ ∅ / δ ⊢ t₁✝ ⦂ Ref τ₁✝ }>ih:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'⊢ <{ !t₁✝ }>.IsValue ∨ ∃ t' ρ', <{ !t₁✝ }> / ρ ⟶ t' / ρ'
right deref δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₁✝:Tmτ₁✝:Tyh:<{ ∅ / δ ⊢ t₁✝ ⦂ Ref τ₁✝ }>ih:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'⊢ ∃ t' ρ', <{ !t₁✝ }> / ρ ⟶ t' / ρ'; cases ih (by δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₁✝:Tmτ₁✝:Tyh:<{ ∅ / δ ⊢ t₁✝ ⦂ Ref τ₁✝ }>ih:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'⊢ ∅ = ∅ rfl All goals completed! 🐙) with
-- t₁ is a value; its typing tells us `l < δ.length`
| inl hv => deref.inl δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₁✝:Tmτ₁✝:Tyh:<{ ∅ / δ ⊢ t₁✝ ⦂ Ref τ₁✝ }>ih:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'hv:t₁✝.IsValue⊢ ∃ t' ρ', <{ !t₁✝ }> / ρ ⟶ t' / ρ'
cases hv with (inversion h All goals completed! 🐙)
| loc_ l => loc_ δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextl:Natih:∅ = ∅ → (Tm.loc l).IsValue ∨ ∃ t' ρ', Tm.loc l / ρ ⟶ t' / ρ'h✝:l < List.length δ⊢ ∃ t' ρ', <{ !~(Tm.loc l) }> / ρ ⟶ t' / ρ' exists ρ[l], ρ loc_ δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextl:Natih:∅ = ∅ → (Tm.loc l).IsValue ∨ ∃ t' ρ', Tm.loc l / ρ ⟶ t' / ρ'h✝:l < List.length δ⊢ <{ !~(Tm.loc l) }> / ρ ⟶ ρ[l] / ρ; apply Step.derefLoc loc_ δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextl:Natih:∅ = ∅ → (Tm.loc l).IsValue ∨ ∃ t' ρ', Tm.loc l / ρ ⟶ t' / ρ'h✝:l < List.length δ⊢ l < List.length ρ; lia All goals completed! 🐙
-- t₁ steps
| inr hs => deref.inr δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₁✝:Tmτ₁✝:Tyh:<{ ∅ / δ ⊢ t₁✝ ⦂ Ref τ₁✝ }>ih:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'hs:∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'⊢ ∃ t' ρ', <{ !t₁✝ }> / ρ ⟶ t' / ρ'
have ⟨t₁', ρ', hs⟩ := hs deref.inr δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₁✝:Tmτ₁✝:Tyh:<{ ∅ / δ ⊢ t₁✝ ⦂ Ref τ₁✝ }>ih:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'hs✝:∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ't₁':Tmρ':Storehs:t₁✝ / ρ ⟶ t₁' / ρ'⊢ ∃ t' ρ', <{ !t₁✝ }> / ρ ⟶ t' / ρ'
apply Exists.intro deref.inr.h δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₁✝:Tmτ₁✝:Tyh:<{ ∅ / δ ⊢ t₁✝ ⦂ Ref τ₁✝ }>ih:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'hs✝:∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ't₁':Tmρ':Storehs:t₁✝ / ρ ⟶ t₁' / ρ'⊢ ∃ ρ', <{ !t₁✝ }> / ρ ⟶ ?deref.inr.w / ρ'deref.inr.w δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₁✝:Tmτ₁✝:Tyh:<{ ∅ / δ ⊢ t₁✝ ⦂ Ref τ₁✝ }>ih:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'hs✝:∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ't₁':Tmρ':Storehs:t₁✝ / ρ ⟶ t₁' / ρ'⊢ Tm; apply Exists.intro deref.inr.h.h δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₁✝:Tmτ₁✝:Tyh:<{ ∅ / δ ⊢ t₁✝ ⦂ Ref τ₁✝ }>ih:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'hs✝:∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ't₁':Tmρ':Storehs:t₁✝ / ρ ⟶ t₁' / ρ'⊢ <{ !t₁✝ }> / ρ ⟶ ?deref.inr.w / ?deref.inr.h.wderef.inr.h.w δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₁✝:Tmτ₁✝:Tyh:<{ ∅ / δ ⊢ t₁✝ ⦂ Ref τ₁✝ }>ih:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'hs✝:∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ't₁':Tmρ':Storehs:t₁✝ / ρ ⟶ t₁' / ρ'⊢ Storederef.inr.w δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₁✝:Tmτ₁✝:Tyh:<{ ∅ / δ ⊢ t₁✝ ⦂ Ref τ₁✝ }>ih:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'hs✝:∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ't₁':Tmρ':Storehs:t₁✝ / ρ ⟶ t₁' / ρ'⊢ Tm; solve_by_elim using StlcRefEval All goals completed! 🐙
| @assign _ _ t₂ _ h₁ _ ih₁ ih₂ => assign δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₁✝:Tmt₂:Tmτ₂✝:Tyh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ Ref τ₂✝ }>h₂✝:<{ ∅ / δ ⊢ t₂ ⦂ τ₂✝ }>ih₁:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'ih₂:∅ = ∅ → t₂.IsValue ∨ ∃ t' ρ', t₂ / ρ ⟶ t' / ρ'⊢ <{ t₁✝ := t₂ }>.IsValue ∨ ∃ t' ρ', <{ t₁✝ := t₂ }> / ρ ⟶ t' / ρ'
right assign δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₁✝:Tmt₂:Tmτ₂✝:Tyh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ Ref τ₂✝ }>h₂✝:<{ ∅ / δ ⊢ t₂ ⦂ τ₂✝ }>ih₁:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'ih₂:∅ = ∅ → t₂.IsValue ∨ ∃ t' ρ', t₂ / ρ ⟶ t' / ρ'⊢ ∃ t' ρ', <{ t₁✝ := t₂ }> / ρ ⟶ t' / ρ'; cases ih₁ (by δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₁✝:Tmt₂:Tmτ₂✝:Tyh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ Ref τ₂✝ }>h₂✝:<{ ∅ / δ ⊢ t₂ ⦂ τ₂✝ }>ih₁:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'ih₂:∅ = ∅ → t₂.IsValue ∨ ∃ t' ρ', t₂ / ρ ⟶ t' / ρ'⊢ ∅ = ∅ rfl All goals completed! 🐙) with
-- t₁ is a value
| inl hv₁ => assign.inl δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₁✝:Tmt₂:Tmτ₂✝:Tyh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ Ref τ₂✝ }>h₂✝:<{ ∅ / δ ⊢ t₂ ⦂ τ₂✝ }>ih₁:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'ih₂:∅ = ∅ → t₂.IsValue ∨ ∃ t' ρ', t₂ / ρ ⟶ t' / ρ'hv₁:t₁✝.IsValue⊢ ∃ t' ρ', <{ t₁✝ := t₂ }> / ρ ⟶ t' / ρ'
cases ih₂ (by δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₁✝:Tmt₂:Tmτ₂✝:Tyh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ Ref τ₂✝ }>h₂✝:<{ ∅ / δ ⊢ t₂ ⦂ τ₂✝ }>ih₁:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'ih₂:∅ = ∅ → t₂.IsValue ∨ ∃ t' ρ', t₂ / ρ ⟶ t' / ρ'hv₁:t₁✝.IsValue⊢ ∅ = ∅ rfl All goals completed! 🐙) with
-- t₂ is a value
| inl hv₂ => assign.inl.inl δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₁✝:Tmt₂:Tmτ₂✝:Tyh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ Ref τ₂✝ }>h₂✝:<{ ∅ / δ ⊢ t₂ ⦂ τ₂✝ }>ih₁:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'ih₂:∅ = ∅ → t₂.IsValue ∨ ∃ t' ρ', t₂ / ρ ⟶ t' / ρ'hv₁:t₁✝.IsValuehv₂:t₂.IsValue⊢ ∃ t' ρ', <{ t₁✝ := t₂ }> / ρ ⟶ t' / ρ'
cases hv₁ with (inversion h₁ All goals completed! 🐙)
| loc_ l => loc_ δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₂:Tmih₂:∅ = ∅ → t₂.IsValue ∨ ∃ t' ρ', t₂ / ρ ⟶ t' / ρ'hv₂:t₂.IsValuel:Natih₁:∅ = ∅ → (Tm.loc l).IsValue ∨ ∃ t' ρ', Tm.loc l / ρ ⟶ t' / ρ'h✝:l < List.length δh₂✝:<{ ∅ / δ ⊢ t₂ ⦂ ~δ[l] }>⊢ ∃ t' ρ', <{ ~(Tm.loc l) := t₂ }> / ρ ⟶ t' / ρ' exists <{ unit }>, ρ.set l t₂ loc_ δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₂:Tmih₂:∅ = ∅ → t₂.IsValue ∨ ∃ t' ρ', t₂ / ρ ⟶ t' / ρ'hv₂:t₂.IsValuel:Natih₁:∅ = ∅ → (Tm.loc l).IsValue ∨ ∃ t' ρ', Tm.loc l / ρ ⟶ t' / ρ'h✝:l < List.length δh₂✝:<{ ∅ / δ ⊢ t₂ ⦂ ~δ[l] }>⊢ <{ ~(Tm.loc l) := t₂ }> / ρ ⟶ <{ unit }> / List.set ρ l t₂; apply Step.assign hv₂ loc_ δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₂:Tmih₂:∅ = ∅ → t₂.IsValue ∨ ∃ t' ρ', t₂ / ρ ⟶ t' / ρ'hv₂:t₂.IsValuel:Natih₁:∅ = ∅ → (Tm.loc l).IsValue ∨ ∃ t' ρ', Tm.loc l / ρ ⟶ t' / ρ'h✝:l < List.length δh₂✝:<{ ∅ / δ ⊢ t₂ ⦂ ~δ[l] }>⊢ l < List.length ρ; lia All goals completed! 🐙
-- t₂ steps
| inr hs₂ => assign.inl.inr δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₁✝:Tmt₂:Tmτ₂✝:Tyh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ Ref τ₂✝ }>h₂✝:<{ ∅ / δ ⊢ t₂ ⦂ τ₂✝ }>ih₁:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'ih₂:∅ = ∅ → t₂.IsValue ∨ ∃ t' ρ', t₂ / ρ ⟶ t' / ρ'hv₁:t₁✝.IsValuehs₂:∃ t' ρ', t₂ / ρ ⟶ t' / ρ'⊢ ∃ t' ρ', <{ t₁✝ := t₂ }> / ρ ⟶ t' / ρ'
have ⟨_, _, _⟩ := hs₂ assign.inl.inr δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₁✝:Tmt₂:Tmτ₂✝:Tyh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ Ref τ₂✝ }>h₂✝:<{ ∅ / δ ⊢ t₂ ⦂ τ₂✝ }>ih₁:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'ih₂:∅ = ∅ → t₂.IsValue ∨ ∃ t' ρ', t₂ / ρ ⟶ t' / ρ'hv₁:t₁✝.IsValuehs₂:∃ t' ρ', t₂ / ρ ⟶ t' / ρ'w✝¹:Tmw✝:Storeh✝:t₂ / ρ ⟶ w✝¹ / w✝⊢ ∃ t' ρ', <{ t₁✝ := t₂ }> / ρ ⟶ t' / ρ'
apply Exists.intro assign.inl.inr.h δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₁✝:Tmt₂:Tmτ₂✝:Tyh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ Ref τ₂✝ }>h₂✝:<{ ∅ / δ ⊢ t₂ ⦂ τ₂✝ }>ih₁:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'ih₂:∅ = ∅ → t₂.IsValue ∨ ∃ t' ρ', t₂ / ρ ⟶ t' / ρ'hv₁:t₁✝.IsValuehs₂:∃ t' ρ', t₂ / ρ ⟶ t' / ρ'w✝¹:Tmw✝:Storeh✝:t₂ / ρ ⟶ w✝¹ / w✝⊢ ∃ ρ', <{ t₁✝ := t₂ }> / ρ ⟶ ?assign.inl.inr.w / ρ'assign.inl.inr.w δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₁✝:Tmt₂:Tmτ₂✝:Tyh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ Ref τ₂✝ }>h₂✝:<{ ∅ / δ ⊢ t₂ ⦂ τ₂✝ }>ih₁:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'ih₂:∅ = ∅ → t₂.IsValue ∨ ∃ t' ρ', t₂ / ρ ⟶ t' / ρ'hv₁:t₁✝.IsValuehs₂:∃ t' ρ', t₂ / ρ ⟶ t' / ρ'w✝¹:Tmw✝:Storeh✝:t₂ / ρ ⟶ w✝¹ / w✝⊢ Tm; apply Exists.intro assign.inl.inr.h.h δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₁✝:Tmt₂:Tmτ₂✝:Tyh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ Ref τ₂✝ }>h₂✝:<{ ∅ / δ ⊢ t₂ ⦂ τ₂✝ }>ih₁:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'ih₂:∅ = ∅ → t₂.IsValue ∨ ∃ t' ρ', t₂ / ρ ⟶ t' / ρ'hv₁:t₁✝.IsValuehs₂:∃ t' ρ', t₂ / ρ ⟶ t' / ρ'w✝¹:Tmw✝:Storeh✝:t₂ / ρ ⟶ w✝¹ / w✝⊢ <{ t₁✝ := t₂ }> / ρ ⟶ ?assign.inl.inr.w / ?assign.inl.inr.h.wassign.inl.inr.h.w δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₁✝:Tmt₂:Tmτ₂✝:Tyh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ Ref τ₂✝ }>h₂✝:<{ ∅ / δ ⊢ t₂ ⦂ τ₂✝ }>ih₁:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'ih₂:∅ = ∅ → t₂.IsValue ∨ ∃ t' ρ', t₂ / ρ ⟶ t' / ρ'hv₁:t₁✝.IsValuehs₂:∃ t' ρ', t₂ / ρ ⟶ t' / ρ'w✝¹:Tmw✝:Storeh✝:t₂ / ρ ⟶ w✝¹ / w✝⊢ Storeassign.inl.inr.w δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₁✝:Tmt₂:Tmτ₂✝:Tyh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ Ref τ₂✝ }>h₂✝:<{ ∅ / δ ⊢ t₂ ⦂ τ₂✝ }>ih₁:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'ih₂:∅ = ∅ → t₂.IsValue ∨ ∃ t' ρ', t₂ / ρ ⟶ t' / ρ'hv₁:t₁✝.IsValuehs₂:∃ t' ρ', t₂ / ρ ⟶ t' / ρ'w✝¹:Tmw✝:Storeh✝:t₂ / ρ ⟶ w✝¹ / w✝⊢ Tm; solve_by_elim using StlcRefEval All goals completed! 🐙
-- t₁ steps
| inr hs₁ => assign.inr δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₁✝:Tmt₂:Tmτ₂✝:Tyh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ Ref τ₂✝ }>h₂✝:<{ ∅ / δ ⊢ t₂ ⦂ τ₂✝ }>ih₁:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'ih₂:∅ = ∅ → t₂.IsValue ∨ ∃ t' ρ', t₂ / ρ ⟶ t' / ρ'hs₁:∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'⊢ ∃ t' ρ', <{ t₁✝ := t₂ }> / ρ ⟶ t' / ρ'
have ⟨t₁', ρ', hs₁⟩ := hs₁ assign.inr δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₁✝:Tmt₂:Tmτ₂✝:Tyh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ Ref τ₂✝ }>h₂✝:<{ ∅ / δ ⊢ t₂ ⦂ τ₂✝ }>ih₁:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'ih₂:∅ = ∅ → t₂.IsValue ∨ ∃ t' ρ', t₂ / ρ ⟶ t' / ρ'hs₁✝:∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ't₁':Tmρ':Storehs₁:t₁✝ / ρ ⟶ t₁' / ρ'⊢ ∃ t' ρ', <{ t₁✝ := t₂ }> / ρ ⟶ t' / ρ'
apply Exists.intro assign.inr.h δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₁✝:Tmt₂:Tmτ₂✝:Tyh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ Ref τ₂✝ }>h₂✝:<{ ∅ / δ ⊢ t₂ ⦂ τ₂✝ }>ih₁:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'ih₂:∅ = ∅ → t₂.IsValue ∨ ∃ t' ρ', t₂ / ρ ⟶ t' / ρ'hs₁✝:∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ't₁':Tmρ':Storehs₁:t₁✝ / ρ ⟶ t₁' / ρ'⊢ ∃ ρ', <{ t₁✝ := t₂ }> / ρ ⟶ ?assign.inr.w / ρ'assign.inr.w δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₁✝:Tmt₂:Tmτ₂✝:Tyh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ Ref τ₂✝ }>h₂✝:<{ ∅ / δ ⊢ t₂ ⦂ τ₂✝ }>ih₁:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'ih₂:∅ = ∅ → t₂.IsValue ∨ ∃ t' ρ', t₂ / ρ ⟶ t' / ρ'hs₁✝:∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ't₁':Tmρ':Storehs₁:t₁✝ / ρ ⟶ t₁' / ρ'⊢ Tm; apply Exists.intro assign.inr.h.h δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₁✝:Tmt₂:Tmτ₂✝:Tyh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ Ref τ₂✝ }>h₂✝:<{ ∅ / δ ⊢ t₂ ⦂ τ₂✝ }>ih₁:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'ih₂:∅ = ∅ → t₂.IsValue ∨ ∃ t' ρ', t₂ / ρ ⟶ t' / ρ'hs₁✝:∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ't₁':Tmρ':Storehs₁:t₁✝ / ρ ⟶ t₁' / ρ'⊢ <{ t₁✝ := t₂ }> / ρ ⟶ ?assign.inr.w / ?assign.inr.h.wassign.inr.h.w δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₁✝:Tmt₂:Tmτ₂✝:Tyh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ Ref τ₂✝ }>h₂✝:<{ ∅ / δ ⊢ t₂ ⦂ τ₂✝ }>ih₁:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'ih₂:∅ = ∅ → t₂.IsValue ∨ ∃ t' ρ', t₂ / ρ ⟶ t' / ρ'hs₁✝:∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ't₁':Tmρ':Storehs₁:t₁✝ / ρ ⟶ t₁' / ρ'⊢ Storeassign.inr.w δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₁✝:Tmt₂:Tmτ₂✝:Tyh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ Ref τ₂✝ }>h₂✝:<{ ∅ / δ ⊢ t₂ ⦂ τ₂✝ }>ih₁:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'ih₂:∅ = ∅ → t₂.IsValue ∨ ∃ t' ρ', t₂ / ρ ⟶ t' / ρ'hs₁✝:∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ't₁':Tmρ':Storehs₁:t₁✝ / ρ ⟶ t₁' / ρ'⊢ Tm; solve_by_elim using StlcRefEval All goals completed! 🐙
Like the earlier preservation proof, many of these cases are repetitive. Once again we can make the proof more concise using automation:
theorem progress_shorter (δ : StoreTy) (t : Tm) (τ : Ty) (ρ : Store)
(hTy : <{ ∅ / δ ⊢ t ⦂ τ }>)
(hStoreTy : δ ⊢ ρ) :
(t.IsValue ∨ ∃ t' ρ', t / ρ ⟶ t' / ρ') := by δ:StoreTyt:Tmτ:Tyρ:StorehTy:<{ ∅ / δ ⊢ t ⦂ τ }>hStoreTy:δ ⊢ ρ⊢ t.IsValue ∨ ∃ t' ρ', t / ρ ⟶ t' / ρ'
have ⟨hLen, _⟩ := hStoreTy δ:StoreTyt:Tmτ:Tyρ:StorehTy:<{ ∅ / δ ⊢ t ⦂ τ }>hStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>⊢ t.IsValue ∨ ∃ t' ρ', t / ρ ⟶ t' / ρ'
generalize heq : (∅ : Context) = Γ at hTy δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextheq:∅ = ΓhTy:<{ Γ / δ ⊢ t ⦂ τ }>⊢ t.IsValue ∨ ∃ t' ρ', t / ρ ⟶ t' / ρ'
induction hTy with (
subst_vars ref_ δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₁✝:Tmτ₁✝:Tyh✝:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₁✝ }>h_ih✝:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'⊢ <{ ref t₁✝ }>.IsValue ∨ ∃ t' ρ', <{ ref t₁✝ }> / ρ ⟶ t' / ρ'; first
| contradiction ref_ δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₁✝:Tmτ₁✝:Tyh✝:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₁✝ }>h_ih✝:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'⊢ <{ ref t₁✝ }>.IsValue ∨ ∃ t' ρ', <{ ref t₁✝ }> / ρ ⟶ t' / ρ'
-- discharge cases where `t` is obviously a value
| (left ref_ δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₁✝:Tmτ₁✝:Tyh✝:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₁✝ }>h_ih✝:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'⊢ <{ ref t₁✝ }>.IsValue; constructor ref_ δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₁✝:Tmτ₁✝:Tyh✝:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₁✝ }>h_ih✝:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'⊢ <{ ref t₁✝ }>.IsValue; done)
-- otherwise, `t` steps
| (right ref_ δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₁✝:Tmτ₁✝:Tyh✝:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₁✝ }>h_ih✝:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'⊢ ∃ t' ρ', <{ ref t₁✝ }> / ρ ⟶ t' / ρ'
-- we use the same trick as in the preservation proof
-- to get around our unnamed `ih`
(obtain hv | ⟨t', ρ', hs⟩ : Tm.IsValue _ ∨ ∃ t' ρ', _ / ρ ⟶ t' / ρ' := by δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₁✝:Tmτ₁✝:Tyh✝:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₁✝ }>h_ih✝:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'⊢ Tm.IsValue ?m.9698 ∨ ∃ t' ρ', ?m.9709 t' ρ' / ρ ⟶ t' / ρ'
solve_by_elim ref_.inl δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₁✝:Tmτ₁✝:Tyh✝:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₁✝ }>h_ih✝:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'hv:t₁✝.IsValue⊢ ∃ t' ρ', <{ ref t₁✝ }> / ρ ⟶ t' / ρ'ref_.inr δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₁✝:Tmτ₁✝:Tyh✝:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₁✝ }>h_ih✝:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ't':Tmρ':Storehs:t₁✝ / ρ ⟶ t' / ρ'⊢ ∃ t' ρ', <{ ref t₁✝ }> / ρ ⟶ t' / ρ') <;> ref_.inl δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₁✝:Tmτ₁✝:Tyh✝:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₁✝ }>h_ih✝:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'hv:t₁✝.IsValue⊢ ∃ t' ρ', <{ ref t₁✝ }> / ρ ⟶ t' / ρ'ref_.inr δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₁✝:Tmτ₁✝:Tyh✝:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₁✝ }>h_ih✝:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ't':Tmρ':Storehs:t₁✝ / ρ ⟶ t' / ρ'⊢ ∃ t' ρ', <{ ref t₁✝ }> / ρ ⟶ t' / ρ'
-- handle simple cases where `t`'s type gives us
-- one possible value
try
(try (cases hv ref_.inr δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₁✝:Tmτ₁✝:Tyh✝:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₁✝ }>h_ih✝:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ't':Tmρ':Storehs:t₁✝ / ρ ⟶ t' / ρ'⊢ ∃ t' ρ', <{ ref t₁✝ }> / ρ ⟶ t' / ρ' <;> ref_.inl.abs δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextτ₁✝:Tyx✝:Stringτ₂✝:Tyt₁✝:Tmh✝:<{ ∅ / δ ⊢ λ ~x✝ : τ₂✝ . t₁✝ ⦂ τ₁✝ }>h_ih✝:∅ = ∅ → <{ λ ~x✝ : τ₂✝ . t₁✝ }>.IsValue ∨ ∃ t' ρ', <{ λ ~x✝ : τ₂✝ . t₁✝ }> / ρ ⟶ t' / ρ'⊢ ∃ t' ρ', <{ ref (λ ~x✝ : τ₂✝ . t₁✝) }> / ρ ⟶ t' / ρ'ref_.inl.nat δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextτ₁✝:Tyn✝:Nath✝:<{ ∅ / δ ⊢ ~(Tm.const n✝) ⦂ τ₁✝ }>h_ih✝:∅ = ∅ → (Tm.const n✝).IsValue ∨ ∃ t' ρ', Tm.const n✝ / ρ ⟶ t' / ρ'⊢ ∃ t' ρ', <{ ref ~(Tm.const n✝) }> / ρ ⟶ t' / ρ'ref_.inl.unit δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextτ₁✝:Tyh✝:<{ ∅ / δ ⊢ unit ⦂ τ₁✝ }>h_ih✝:∅ = ∅ → <{ unit }>.IsValue ∨ ∃ t' ρ', <{ unit }> / ρ ⟶ t' / ρ'⊢ ∃ t' ρ', <{ ref unit }> / ρ ⟶ t' / ρ'ref_.inl.loc_ δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextτ₁✝:Tyl✝:Nath✝:<{ ∅ / δ ⊢ ~(Tm.loc l✝) ⦂ τ₁✝ }>h_ih✝:∅ = ∅ → (Tm.loc l✝).IsValue ∨ ∃ t' ρ', Tm.loc l✝ / ρ ⟶ t' / ρ'⊢ ∃ t' ρ', <{ ref ~(Tm.loc l✝) }> / ρ ⟶ t' / ρ' try contradiction ref_.inl.loc_ δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextτ₁✝:Tyl✝:Nath✝:<{ ∅ / δ ⊢ ~(Tm.loc l✝) ⦂ τ₁✝ }>h_ih✝:∅ = ∅ → (Tm.loc l✝).IsValue ∨ ∃ t' ρ', Tm.loc l✝ / ρ ⟶ t' / ρ'⊢ ∃ t' ρ', <{ ref ~(Tm.loc l✝) }> / ρ ⟶ t' / ρ')) <;> ref_.inr δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₁✝:Tmτ₁✝:Tyh✝:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₁✝ }>h_ih✝:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ't':Tmρ':Storehs:t₁✝ / ρ ⟶ t' / ρ'⊢ ∃ t' ρ', <{ ref t₁✝ }> / ρ ⟶ t' / ρ'
(apply Exists.intro ref_.inr.h δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₁✝:Tmτ₁✝:Tyh✝:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₁✝ }>h_ih✝:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ't':Tmρ':Storehs:t₁✝ / ρ ⟶ t' / ρ'⊢ ∃ ρ', <{ ref t₁✝ }> / ρ ⟶ ?ref_.inr.w / ρ'ref_.inr.w δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₁✝:Tmτ₁✝:Tyh✝:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₁✝ }>h_ih✝:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ't':Tmρ':Storehs:t₁✝ / ρ ⟶ t' / ρ'⊢ Tm; apply Exists.intro ref_.inr.h.h δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₁✝:Tmτ₁✝:Tyh✝:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₁✝ }>h_ih✝:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ't':Tmρ':Storehs:t₁✝ / ρ ⟶ t' / ρ'⊢ <{ ref t₁✝ }> / ρ ⟶ ?ref_.inr.w / ?ref_.inr.h.wref_.inr.h.w δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₁✝:Tmτ₁✝:Tyh✝:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₁✝ }>h_ih✝:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ't':Tmρ':Storehs:t₁✝ / ρ ⟶ t' / ρ'⊢ Storeref_.inr.w δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₁✝:Tmτ₁✝:Tyh✝:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₁✝ }>h_ih✝:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ't':Tmρ':Storehs:t₁✝ / ρ ⟶ t' / ρ'⊢ Tm; solve_by_elim using StlcRefEval All goals completed! 🐙)))
| app h₁ _ _ ih₂ => app.inl δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextτ₁✝:Tyτ₂✝:Tyt₁✝:Tmt₂✝:Tmh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ τ₂✝ → τ₁✝ }>h₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ τ₂✝ }>h₁_ih✝:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'ih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'hv:t₁✝.IsValue⊢ ∃ t' ρ', <{ t₁✝ t₂✝ }> / ρ ⟶ t' / ρ'
cases hv app.inl.abs δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextτ₁✝:Tyτ₂✝¹:Tyt₂✝:Tmh₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ τ₂✝ }>ih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'x✝:Stringτ₂✝:Tyt₁✝:Tmh₁:<{ ∅ / δ ⊢ λ ~x✝ : τ₂✝ . t₁✝ ⦂ τ₂✝¹ → τ₁✝ }>h₁_ih✝:∅ = ∅ → <{ λ ~x✝ : τ₂✝ . t₁✝ }>.IsValue ∨ ∃ t' ρ', <{ λ ~x✝ : τ₂✝ . t₁✝ }> / ρ ⟶ t' / ρ'⊢ ∃ t' ρ', <{ (λ ~x✝ : τ₂✝ . t₁✝) t₂✝ }> / ρ ⟶ t' / ρ'app.inl.nat δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextτ₁✝:Tyτ₂✝:Tyt₂✝:Tmh₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ τ₂✝ }>ih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'n✝:Nath₁:<{ ∅ / δ ⊢ ~(Tm.const n✝) ⦂ τ₂✝ → τ₁✝ }>h₁_ih✝:∅ = ∅ → (Tm.const n✝).IsValue ∨ ∃ t' ρ', Tm.const n✝ / ρ ⟶ t' / ρ'⊢ ∃ t' ρ', <{ ~(Tm.const n✝) t₂✝ }> / ρ ⟶ t' / ρ'app.inl.unit δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextτ₁✝:Tyτ₂✝:Tyt₂✝:Tmh₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ τ₂✝ }>ih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'h₁:<{ ∅ / δ ⊢ unit ⦂ τ₂✝ → τ₁✝ }>h₁_ih✝:∅ = ∅ → <{ unit }>.IsValue ∨ ∃ t' ρ', <{ unit }> / ρ ⟶ t' / ρ'⊢ ∃ t' ρ', <{ unit t₂✝ }> / ρ ⟶ t' / ρ'app.inl.loc_ δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextτ₁✝:Tyτ₂✝:Tyt₂✝:Tmh₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ τ₂✝ }>ih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'l✝:Nath₁:<{ ∅ / δ ⊢ ~(Tm.loc l✝) ⦂ τ₂✝ → τ₁✝ }>h₁_ih✝:∅ = ∅ → (Tm.loc l✝).IsValue ∨ ∃ t' ρ', Tm.loc l✝ / ρ ⟶ t' / ρ'⊢ ∃ t' ρ', <{ ~(Tm.loc l✝) t₂✝ }> / ρ ⟶ t' / ρ' <;> app.inl.abs δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextτ₁✝:Tyτ₂✝¹:Tyt₂✝:Tmh₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ τ₂✝ }>ih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'x✝:Stringτ₂✝:Tyt₁✝:Tmh₁:<{ ∅ / δ ⊢ λ ~x✝ : τ₂✝ . t₁✝ ⦂ τ₂✝¹ → τ₁✝ }>h₁_ih✝:∅ = ∅ → <{ λ ~x✝ : τ₂✝ . t₁✝ }>.IsValue ∨ ∃ t' ρ', <{ λ ~x✝ : τ₂✝ . t₁✝ }> / ρ ⟶ t' / ρ'⊢ ∃ t' ρ', <{ (λ ~x✝ : τ₂✝ . t₁✝) t₂✝ }> / ρ ⟶ t' / ρ'app.inl.nat δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextτ₁✝:Tyτ₂✝:Tyt₂✝:Tmh₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ τ₂✝ }>ih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'n✝:Nath₁:<{ ∅ / δ ⊢ ~(Tm.const n✝) ⦂ τ₂✝ → τ₁✝ }>h₁_ih✝:∅ = ∅ → (Tm.const n✝).IsValue ∨ ∃ t' ρ', Tm.const n✝ / ρ ⟶ t' / ρ'⊢ ∃ t' ρ', <{ ~(Tm.const n✝) t₂✝ }> / ρ ⟶ t' / ρ'app.inl.unit δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextτ₁✝:Tyτ₂✝:Tyt₂✝:Tmh₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ τ₂✝ }>ih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'h₁:<{ ∅ / δ ⊢ unit ⦂ τ₂✝ → τ₁✝ }>h₁_ih✝:∅ = ∅ → <{ unit }>.IsValue ∨ ∃ t' ρ', <{ unit }> / ρ ⟶ t' / ρ'⊢ ∃ t' ρ', <{ unit t₂✝ }> / ρ ⟶ t' / ρ'app.inl.loc_ δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextτ₁✝:Tyτ₂✝:Tyt₂✝:Tmh₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ τ₂✝ }>ih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'l✝:Nath₁:<{ ∅ / δ ⊢ ~(Tm.loc l✝) ⦂ τ₂✝ → τ₁✝ }>h₁_ih✝:∅ = ∅ → (Tm.loc l✝).IsValue ∨ ∃ t' ρ', Tm.loc l✝ / ρ ⟶ t' / ρ'⊢ ∃ t' ρ', <{ ~(Tm.loc l✝) t₂✝ }> / ρ ⟶ t' / ρ' inversion h₁ All goals completed! 🐙
obtain hv₂ | ⟨t₂', ρ', hs₂⟩ := ih₂ (by δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextτ₁✝:Tyτ₂✝:Tyt₂✝:Tmh₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ τ₂✝ }>ih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'x✝:Stringt₁✝:Tmh₁_ih✝:∅ = ∅ → <{ λ ~x✝ : τ₂✝ . t₁✝ }>.IsValue ∨ ∃ t' ρ', <{ λ ~x✝ : τ₂✝ . t₁✝ }> / ρ ⟶ t' / ρ'h✝:<{ ~(x✝ →ₚ τ₂✝) / δ ⊢ t₁✝ ⦂ τ₁✝ }>⊢ ∅ = ∅ rfl All goals completed! 🐙) abs.inl δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextτ₁✝:Tyτ₂✝:Tyt₂✝:Tmh₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ τ₂✝ }>ih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'x✝:Stringt₁✝:Tmh₁_ih✝:∅ = ∅ → <{ λ ~x✝ : τ₂✝ . t₁✝ }>.IsValue ∨ ∃ t' ρ', <{ λ ~x✝ : τ₂✝ . t₁✝ }> / ρ ⟶ t' / ρ'h✝:<{ ~(x✝ →ₚ τ₂✝) / δ ⊢ t₁✝ ⦂ τ₁✝ }>hv₂:t₂✝.IsValue⊢ ∃ t' ρ', <{ (λ ~x✝ : τ₂✝ . t₁✝) t₂✝ }> / ρ ⟶ t' / ρ'abs.inr δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextτ₁✝:Tyτ₂✝:Tyt₂✝:Tmh₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ τ₂✝ }>ih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'x✝:Stringt₁✝:Tmh₁_ih✝:∅ = ∅ → <{ λ ~x✝ : τ₂✝ . t₁✝ }>.IsValue ∨ ∃ t' ρ', <{ λ ~x✝ : τ₂✝ . t₁✝ }> / ρ ⟶ t' / ρ'h✝:<{ ~(x✝ →ₚ τ₂✝) / δ ⊢ t₁✝ ⦂ τ₁✝ }>t₂':Tmρ':Storehs₂:t₂✝ / ρ ⟶ t₂' / ρ'⊢ ∃ t' ρ', <{ (λ ~x✝ : τ₂✝ . t₁✝) t₂✝ }> / ρ ⟶ t' / ρ' <;> abs.inl δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextτ₁✝:Tyτ₂✝:Tyt₂✝:Tmh₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ τ₂✝ }>ih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'x✝:Stringt₁✝:Tmh₁_ih✝:∅ = ∅ → <{ λ ~x✝ : τ₂✝ . t₁✝ }>.IsValue ∨ ∃ t' ρ', <{ λ ~x✝ : τ₂✝ . t₁✝ }> / ρ ⟶ t' / ρ'h✝:<{ ~(x✝ →ₚ τ₂✝) / δ ⊢ t₁✝ ⦂ τ₁✝ }>hv₂:t₂✝.IsValue⊢ ∃ t' ρ', <{ (λ ~x✝ : τ₂✝ . t₁✝) t₂✝ }> / ρ ⟶ t' / ρ'abs.inr δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextτ₁✝:Tyτ₂✝:Tyt₂✝:Tmh₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ τ₂✝ }>ih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'x✝:Stringt₁✝:Tmh₁_ih✝:∅ = ∅ → <{ λ ~x✝ : τ₂✝ . t₁✝ }>.IsValue ∨ ∃ t' ρ', <{ λ ~x✝ : τ₂✝ . t₁✝ }> / ρ ⟶ t' / ρ'h✝:<{ ~(x✝ →ₚ τ₂✝) / δ ⊢ t₁✝ ⦂ τ₁✝ }>t₂':Tmρ':Storehs₂:t₂✝ / ρ ⟶ t₂' / ρ'⊢ ∃ t' ρ', <{ (λ ~x✝ : τ₂✝ . t₁✝) t₂✝ }> / ρ ⟶ t' / ρ'
(apply Exists.intro abs.inr.h δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextτ₁✝:Tyτ₂✝:Tyt₂✝:Tmh₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ τ₂✝ }>ih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'x✝:Stringt₁✝:Tmh₁_ih✝:∅ = ∅ → <{ λ ~x✝ : τ₂✝ . t₁✝ }>.IsValue ∨ ∃ t' ρ', <{ λ ~x✝ : τ₂✝ . t₁✝ }> / ρ ⟶ t' / ρ'h✝:<{ ~(x✝ →ₚ τ₂✝) / δ ⊢ t₁✝ ⦂ τ₁✝ }>t₂':Tmρ':Storehs₂:t₂✝ / ρ ⟶ t₂' / ρ'⊢ ∃ ρ', <{ (λ ~x✝ : τ₂✝ . t₁✝) t₂✝ }> / ρ ⟶ ?abs.inr.w / ρ'abs.inr.w δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextτ₁✝:Tyτ₂✝:Tyt₂✝:Tmh₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ τ₂✝ }>ih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'x✝:Stringt₁✝:Tmh₁_ih✝:∅ = ∅ → <{ λ ~x✝ : τ₂✝ . t₁✝ }>.IsValue ∨ ∃ t' ρ', <{ λ ~x✝ : τ₂✝ . t₁✝ }> / ρ ⟶ t' / ρ'h✝:<{ ~(x✝ →ₚ τ₂✝) / δ ⊢ t₁✝ ⦂ τ₁✝ }>t₂':Tmρ':Storehs₂:t₂✝ / ρ ⟶ t₂' / ρ'⊢ Tm; apply Exists.intro abs.inr.h.h δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextτ₁✝:Tyτ₂✝:Tyt₂✝:Tmh₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ τ₂✝ }>ih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'x✝:Stringt₁✝:Tmh₁_ih✝:∅ = ∅ → <{ λ ~x✝ : τ₂✝ . t₁✝ }>.IsValue ∨ ∃ t' ρ', <{ λ ~x✝ : τ₂✝ . t₁✝ }> / ρ ⟶ t' / ρ'h✝:<{ ~(x✝ →ₚ τ₂✝) / δ ⊢ t₁✝ ⦂ τ₁✝ }>t₂':Tmρ':Storehs₂:t₂✝ / ρ ⟶ t₂' / ρ'⊢ <{ (λ ~x✝ : τ₂✝ . t₁✝) t₂✝ }> / ρ ⟶ ?abs.inr.w / ?abs.inr.h.wabs.inr.h.w δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextτ₁✝:Tyτ₂✝:Tyt₂✝:Tmh₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ τ₂✝ }>ih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'x✝:Stringt₁✝:Tmh₁_ih✝:∅ = ∅ → <{ λ ~x✝ : τ₂✝ . t₁✝ }>.IsValue ∨ ∃ t' ρ', <{ λ ~x✝ : τ₂✝ . t₁✝ }> / ρ ⟶ t' / ρ'h✝:<{ ~(x✝ →ₚ τ₂✝) / δ ⊢ t₁✝ ⦂ τ₁✝ }>t₂':Tmρ':Storehs₂:t₂✝ / ρ ⟶ t₂' / ρ'⊢ Storeabs.inr.w δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextτ₁✝:Tyτ₂✝:Tyt₂✝:Tmh₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ τ₂✝ }>ih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'x✝:Stringt₁✝:Tmh₁_ih✝:∅ = ∅ → <{ λ ~x✝ : τ₂✝ . t₁✝ }>.IsValue ∨ ∃ t' ρ', <{ λ ~x✝ : τ₂✝ . t₁✝ }> / ρ ⟶ t' / ρ'h✝:<{ ~(x✝ →ₚ τ₂✝) / δ ⊢ t₁✝ ⦂ τ₁✝ }>t₂':Tmρ':Storehs₂:t₂✝ / ρ ⟶ t₂' / ρ'⊢ Tm; solve_by_elim using StlcRefEval All goals completed! 🐙)
| mult h₁ h₂ _ ih₂ => mult.inl δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₁✝:Tmt₂✝:Tmh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ Nat }>h₂:<{ ∅ / δ ⊢ t₂✝ ⦂ Nat }>h₁_ih✝:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'ih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'hv:t₁✝.IsValue⊢ ∃ t' ρ', <{ t₁✝ * t₂✝ }> / ρ ⟶ t' / ρ'
cases hv mult.inl.abs δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₂✝:Tmh₂:<{ ∅ / δ ⊢ t₂✝ ⦂ Nat }>ih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'x✝:Stringτ₂✝:Tyt₁✝:Tmh₁:<{ ∅ / δ ⊢ λ ~x✝ : τ₂✝ . t₁✝ ⦂ Nat }>h₁_ih✝:∅ = ∅ → <{ λ ~x✝ : τ₂✝ . t₁✝ }>.IsValue ∨ ∃ t' ρ', <{ λ ~x✝ : τ₂✝ . t₁✝ }> / ρ ⟶ t' / ρ'⊢ ∃ t' ρ', <{ (λ ~x✝ : τ₂✝ . t₁✝) * t₂✝ }> / ρ ⟶ t' / ρ'mult.inl.nat δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₂✝:Tmh₂:<{ ∅ / δ ⊢ t₂✝ ⦂ Nat }>ih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'n✝:Nath₁:<{ ∅ / δ ⊢ ~(Tm.const n✝) ⦂ Nat }>h₁_ih✝:∅ = ∅ → (Tm.const n✝).IsValue ∨ ∃ t' ρ', Tm.const n✝ / ρ ⟶ t' / ρ'⊢ ∃ t' ρ', <{ ~(Tm.const n✝) * t₂✝ }> / ρ ⟶ t' / ρ'mult.inl.unit δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₂✝:Tmh₂:<{ ∅ / δ ⊢ t₂✝ ⦂ Nat }>ih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'h₁:<{ ∅ / δ ⊢ unit ⦂ Nat }>h₁_ih✝:∅ = ∅ → <{ unit }>.IsValue ∨ ∃ t' ρ', <{ unit }> / ρ ⟶ t' / ρ'⊢ ∃ t' ρ', <{ unit * t₂✝ }> / ρ ⟶ t' / ρ'mult.inl.loc_ δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₂✝:Tmh₂:<{ ∅ / δ ⊢ t₂✝ ⦂ Nat }>ih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'l✝:Nath₁:<{ ∅ / δ ⊢ ~(Tm.loc l✝) ⦂ Nat }>h₁_ih✝:∅ = ∅ → (Tm.loc l✝).IsValue ∨ ∃ t' ρ', Tm.loc l✝ / ρ ⟶ t' / ρ'⊢ ∃ t' ρ', <{ ~(Tm.loc l✝) * t₂✝ }> / ρ ⟶ t' / ρ' <;> mult.inl.abs δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₂✝:Tmh₂:<{ ∅ / δ ⊢ t₂✝ ⦂ Nat }>ih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'x✝:Stringτ₂✝:Tyt₁✝:Tmh₁:<{ ∅ / δ ⊢ λ ~x✝ : τ₂✝ . t₁✝ ⦂ Nat }>h₁_ih✝:∅ = ∅ → <{ λ ~x✝ : τ₂✝ . t₁✝ }>.IsValue ∨ ∃ t' ρ', <{ λ ~x✝ : τ₂✝ . t₁✝ }> / ρ ⟶ t' / ρ'⊢ ∃ t' ρ', <{ (λ ~x✝ : τ₂✝ . t₁✝) * t₂✝ }> / ρ ⟶ t' / ρ'mult.inl.nat δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₂✝:Tmh₂:<{ ∅ / δ ⊢ t₂✝ ⦂ Nat }>ih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'n✝:Nath₁:<{ ∅ / δ ⊢ ~(Tm.const n✝) ⦂ Nat }>h₁_ih✝:∅ = ∅ → (Tm.const n✝).IsValue ∨ ∃ t' ρ', Tm.const n✝ / ρ ⟶ t' / ρ'⊢ ∃ t' ρ', <{ ~(Tm.const n✝) * t₂✝ }> / ρ ⟶ t' / ρ'mult.inl.unit δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₂✝:Tmh₂:<{ ∅ / δ ⊢ t₂✝ ⦂ Nat }>ih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'h₁:<{ ∅ / δ ⊢ unit ⦂ Nat }>h₁_ih✝:∅ = ∅ → <{ unit }>.IsValue ∨ ∃ t' ρ', <{ unit }> / ρ ⟶ t' / ρ'⊢ ∃ t' ρ', <{ unit * t₂✝ }> / ρ ⟶ t' / ρ'mult.inl.loc_ δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₂✝:Tmh₂:<{ ∅ / δ ⊢ t₂✝ ⦂ Nat }>ih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'l✝:Nath₁:<{ ∅ / δ ⊢ ~(Tm.loc l✝) ⦂ Nat }>h₁_ih✝:∅ = ∅ → (Tm.loc l✝).IsValue ∨ ∃ t' ρ', Tm.loc l✝ / ρ ⟶ t' / ρ'⊢ ∃ t' ρ', <{ ~(Tm.loc l✝) * t₂✝ }> / ρ ⟶ t' / ρ' try contradiction All goals completed! 🐙
cases ih₂ (by δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₂✝:Tmh₂:<{ ∅ / δ ⊢ t₂✝ ⦂ Nat }>ih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'n✝:Nath₁:<{ ∅ / δ ⊢ ~(Tm.const n✝) ⦂ Nat }>h₁_ih✝:∅ = ∅ → (Tm.const n✝).IsValue ∨ ∃ t' ρ', Tm.const n✝ / ρ ⟶ t' / ρ'⊢ ∅ = ∅ rfl All goals completed! 🐙) with
| inl hv₂ => mult.inl.nat.inl δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₂✝:Tmh₂:<{ ∅ / δ ⊢ t₂✝ ⦂ Nat }>ih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'n✝:Nath₁:<{ ∅ / δ ⊢ ~(Tm.const n✝) ⦂ Nat }>h₁_ih✝:∅ = ∅ → (Tm.const n✝).IsValue ∨ ∃ t' ρ', Tm.const n✝ / ρ ⟶ t' / ρ'hv₂:t₂✝.IsValue⊢ ∃ t' ρ', <{ ~(Tm.const n✝) * t₂✝ }> / ρ ⟶ t' / ρ'
cases hv₂ mult.inl.nat.inl.abs δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextn✝:Nath₁:<{ ∅ / δ ⊢ ~(Tm.const n✝) ⦂ Nat }>h₁_ih✝:∅ = ∅ → (Tm.const n✝).IsValue ∨ ∃ t' ρ', Tm.const n✝ / ρ ⟶ t' / ρ'x✝:Stringτ₂✝:Tyt₁✝:Tmh₂:<{ ∅ / δ ⊢ λ ~x✝ : τ₂✝ . t₁✝ ⦂ Nat }>ih₂:∅ = ∅ → <{ λ ~x✝ : τ₂✝ . t₁✝ }>.IsValue ∨ ∃ t' ρ', <{ λ ~x✝ : τ₂✝ . t₁✝ }> / ρ ⟶ t' / ρ'⊢ ∃ t' ρ', <{ ~(Tm.const n✝) * (λ ~x✝ : τ₂✝ . t₁✝) }> / ρ ⟶ t' / ρ'mult.inl.nat.inl.nat δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextn✝¹:Nath₁:<{ ∅ / δ ⊢ ~(Tm.const n✝) ⦂ Nat }>h₁_ih✝:∅ = ∅ → (Tm.const n✝).IsValue ∨ ∃ t' ρ', Tm.const n✝ / ρ ⟶ t' / ρ'n✝:Nath₂:<{ ∅ / δ ⊢ ~(Tm.const n✝) ⦂ Nat }>ih₂:∅ = ∅ → (Tm.const n✝).IsValue ∨ ∃ t' ρ', Tm.const n✝ / ρ ⟶ t' / ρ'⊢ ∃ t' ρ', <{ ~(Tm.const n✝¹) * ~(Tm.const n✝) }> / ρ ⟶ t' / ρ'mult.inl.nat.inl.unit δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextn✝:Nath₁:<{ ∅ / δ ⊢ ~(Tm.const n✝) ⦂ Nat }>h₁_ih✝:∅ = ∅ → (Tm.const n✝).IsValue ∨ ∃ t' ρ', Tm.const n✝ / ρ ⟶ t' / ρ'h₂:<{ ∅ / δ ⊢ unit ⦂ Nat }>ih₂:∅ = ∅ → <{ unit }>.IsValue ∨ ∃ t' ρ', <{ unit }> / ρ ⟶ t' / ρ'⊢ ∃ t' ρ', <{ ~(Tm.const n✝) * unit }> / ρ ⟶ t' / ρ'mult.inl.nat.inl.loc_ δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextn✝:Nath₁:<{ ∅ / δ ⊢ ~(Tm.const n✝) ⦂ Nat }>h₁_ih✝:∅ = ∅ → (Tm.const n✝).IsValue ∨ ∃ t' ρ', Tm.const n✝ / ρ ⟶ t' / ρ'l✝:Nath₂:<{ ∅ / δ ⊢ ~(Tm.loc l✝) ⦂ Nat }>ih₂:∅ = ∅ → (Tm.loc l✝).IsValue ∨ ∃ t' ρ', Tm.loc l✝ / ρ ⟶ t' / ρ'⊢ ∃ t' ρ', <{ ~(Tm.const n✝) * ~(Tm.loc l✝) }> / ρ ⟶ t' / ρ' <;> mult.inl.nat.inl.abs δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextn✝:Nath₁:<{ ∅ / δ ⊢ ~(Tm.const n✝) ⦂ Nat }>h₁_ih✝:∅ = ∅ → (Tm.const n✝).IsValue ∨ ∃ t' ρ', Tm.const n✝ / ρ ⟶ t' / ρ'x✝:Stringτ₂✝:Tyt₁✝:Tmh₂:<{ ∅ / δ ⊢ λ ~x✝ : τ₂✝ . t₁✝ ⦂ Nat }>ih₂:∅ = ∅ → <{ λ ~x✝ : τ₂✝ . t₁✝ }>.IsValue ∨ ∃ t' ρ', <{ λ ~x✝ : τ₂✝ . t₁✝ }> / ρ ⟶ t' / ρ'⊢ ∃ t' ρ', <{ ~(Tm.const n✝) * (λ ~x✝ : τ₂✝ . t₁✝) }> / ρ ⟶ t' / ρ'mult.inl.nat.inl.nat δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextn✝¹:Nath₁:<{ ∅ / δ ⊢ ~(Tm.const n✝) ⦂ Nat }>h₁_ih✝:∅ = ∅ → (Tm.const n✝).IsValue ∨ ∃ t' ρ', Tm.const n✝ / ρ ⟶ t' / ρ'n✝:Nath₂:<{ ∅ / δ ⊢ ~(Tm.const n✝) ⦂ Nat }>ih₂:∅ = ∅ → (Tm.const n✝).IsValue ∨ ∃ t' ρ', Tm.const n✝ / ρ ⟶ t' / ρ'⊢ ∃ t' ρ', <{ ~(Tm.const n✝¹) * ~(Tm.const n✝) }> / ρ ⟶ t' / ρ'mult.inl.nat.inl.unit δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextn✝:Nath₁:<{ ∅ / δ ⊢ ~(Tm.const n✝) ⦂ Nat }>h₁_ih✝:∅ = ∅ → (Tm.const n✝).IsValue ∨ ∃ t' ρ', Tm.const n✝ / ρ ⟶ t' / ρ'h₂:<{ ∅ / δ ⊢ unit ⦂ Nat }>ih₂:∅ = ∅ → <{ unit }>.IsValue ∨ ∃ t' ρ', <{ unit }> / ρ ⟶ t' / ρ'⊢ ∃ t' ρ', <{ ~(Tm.const n✝) * unit }> / ρ ⟶ t' / ρ'mult.inl.nat.inl.loc_ δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextn✝:Nath₁:<{ ∅ / δ ⊢ ~(Tm.const n✝) ⦂ Nat }>h₁_ih✝:∅ = ∅ → (Tm.const n✝).IsValue ∨ ∃ t' ρ', Tm.const n✝ / ρ ⟶ t' / ρ'l✝:Nath₂:<{ ∅ / δ ⊢ ~(Tm.loc l✝) ⦂ Nat }>ih₂:∅ = ∅ → (Tm.loc l✝).IsValue ∨ ∃ t' ρ', Tm.loc l✝ / ρ ⟶ t' / ρ'⊢ ∃ t' ρ', <{ ~(Tm.const n✝) * ~(Tm.loc l✝) }> / ρ ⟶ t' / ρ' try contradiction All goals completed! 🐙
apply Exists.intro mult.inl.nat.inl.nat.h δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextn✝¹:Nath₁:<{ ∅ / δ ⊢ ~(Tm.const n✝) ⦂ Nat }>h₁_ih✝:∅ = ∅ → (Tm.const n✝).IsValue ∨ ∃ t' ρ', Tm.const n✝ / ρ ⟶ t' / ρ'n✝:Nath₂:<{ ∅ / δ ⊢ ~(Tm.const n✝) ⦂ Nat }>ih₂:∅ = ∅ → (Tm.const n✝).IsValue ∨ ∃ t' ρ', Tm.const n✝ / ρ ⟶ t' / ρ'⊢ ∃ ρ', <{ ~(Tm.const n✝¹) * ~(Tm.const n✝) }> / ρ ⟶ ?mult.inl.nat.inl.nat.w / ρ'mult.inl.nat.inl.nat.w δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextn✝¹:Nath₁:<{ ∅ / δ ⊢ ~(Tm.const n✝) ⦂ Nat }>h₁_ih✝:∅ = ∅ → (Tm.const n✝).IsValue ∨ ∃ t' ρ', Tm.const n✝ / ρ ⟶ t' / ρ'n✝:Nath₂:<{ ∅ / δ ⊢ ~(Tm.const n✝) ⦂ Nat }>ih₂:∅ = ∅ → (Tm.const n✝).IsValue ∨ ∃ t' ρ', Tm.const n✝ / ρ ⟶ t' / ρ'⊢ Tm; apply Exists.intro mult.inl.nat.inl.nat.h.h δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextn✝¹:Nath₁:<{ ∅ / δ ⊢ ~(Tm.const n✝) ⦂ Nat }>h₁_ih✝:∅ = ∅ → (Tm.const n✝).IsValue ∨ ∃ t' ρ', Tm.const n✝ / ρ ⟶ t' / ρ'n✝:Nath₂:<{ ∅ / δ ⊢ ~(Tm.const n✝) ⦂ Nat }>ih₂:∅ = ∅ → (Tm.const n✝).IsValue ∨ ∃ t' ρ', Tm.const n✝ / ρ ⟶ t' / ρ'⊢ <{ ~(Tm.const n✝¹) * ~(Tm.const n✝) }> / ρ ⟶ ?mult.inl.nat.inl.nat.w / ?mult.inl.nat.inl.nat.h.wmult.inl.nat.inl.nat.h.w δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextn✝¹:Nath₁:<{ ∅ / δ ⊢ ~(Tm.const n✝) ⦂ Nat }>h₁_ih✝:∅ = ∅ → (Tm.const n✝).IsValue ∨ ∃ t' ρ', Tm.const n✝ / ρ ⟶ t' / ρ'n✝:Nath₂:<{ ∅ / δ ⊢ ~(Tm.const n✝) ⦂ Nat }>ih₂:∅ = ∅ → (Tm.const n✝).IsValue ∨ ∃ t' ρ', Tm.const n✝ / ρ ⟶ t' / ρ'⊢ Storemult.inl.nat.inl.nat.w δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextn✝¹:Nath₁:<{ ∅ / δ ⊢ ~(Tm.const n✝) ⦂ Nat }>h₁_ih✝:∅ = ∅ → (Tm.const n✝).IsValue ∨ ∃ t' ρ', Tm.const n✝ / ρ ⟶ t' / ρ'n✝:Nath₂:<{ ∅ / δ ⊢ ~(Tm.const n✝) ⦂ Nat }>ih₂:∅ = ∅ → (Tm.const n✝).IsValue ∨ ∃ t' ρ', Tm.const n✝ / ρ ⟶ t' / ρ'⊢ Tm; solve_by_elim using StlcRefEval All goals completed! 🐙
| inr hs₂ => mult.inl.nat.inr δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₂✝:Tmh₂:<{ ∅ / δ ⊢ t₂✝ ⦂ Nat }>ih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'n✝:Nath₁:<{ ∅ / δ ⊢ ~(Tm.const n✝) ⦂ Nat }>h₁_ih✝:∅ = ∅ → (Tm.const n✝).IsValue ∨ ∃ t' ρ', Tm.const n✝ / ρ ⟶ t' / ρ'hs₂:∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'⊢ ∃ t' ρ', <{ ~(Tm.const n✝) * t₂✝ }> / ρ ⟶ t' / ρ'
have ⟨t₂', ρ', hs₂⟩ := hs₂ mult.inl.nat.inr δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₂✝:Tmh₂:<{ ∅ / δ ⊢ t₂✝ ⦂ Nat }>ih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'n✝:Nath₁:<{ ∅ / δ ⊢ ~(Tm.const n✝) ⦂ Nat }>h₁_ih✝:∅ = ∅ → (Tm.const n✝).IsValue ∨ ∃ t' ρ', Tm.const n✝ / ρ ⟶ t' / ρ'hs₂✝:∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ't₂':Tmρ':Storehs₂:t₂✝ / ρ ⟶ t₂' / ρ'⊢ ∃ t' ρ', <{ ~(Tm.const n✝) * t₂✝ }> / ρ ⟶ t' / ρ'
apply Exists.intro mult.inl.nat.inr.h δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₂✝:Tmh₂:<{ ∅ / δ ⊢ t₂✝ ⦂ Nat }>ih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'n✝:Nath₁:<{ ∅ / δ ⊢ ~(Tm.const n✝) ⦂ Nat }>h₁_ih✝:∅ = ∅ → (Tm.const n✝).IsValue ∨ ∃ t' ρ', Tm.const n✝ / ρ ⟶ t' / ρ'hs₂✝:∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ't₂':Tmρ':Storehs₂:t₂✝ / ρ ⟶ t₂' / ρ'⊢ ∃ ρ', <{ ~(Tm.const n✝) * t₂✝ }> / ρ ⟶ ?mult.inl.nat.inr.w / ρ'mult.inl.nat.inr.w δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₂✝:Tmh₂:<{ ∅ / δ ⊢ t₂✝ ⦂ Nat }>ih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'n✝:Nath₁:<{ ∅ / δ ⊢ ~(Tm.const n✝) ⦂ Nat }>h₁_ih✝:∅ = ∅ → (Tm.const n✝).IsValue ∨ ∃ t' ρ', Tm.const n✝ / ρ ⟶ t' / ρ'hs₂✝:∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ't₂':Tmρ':Storehs₂:t₂✝ / ρ ⟶ t₂' / ρ'⊢ Tm; apply Exists.intro mult.inl.nat.inr.h.h δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₂✝:Tmh₂:<{ ∅ / δ ⊢ t₂✝ ⦂ Nat }>ih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'n✝:Nath₁:<{ ∅ / δ ⊢ ~(Tm.const n✝) ⦂ Nat }>h₁_ih✝:∅ = ∅ → (Tm.const n✝).IsValue ∨ ∃ t' ρ', Tm.const n✝ / ρ ⟶ t' / ρ'hs₂✝:∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ't₂':Tmρ':Storehs₂:t₂✝ / ρ ⟶ t₂' / ρ'⊢ <{ ~(Tm.const n✝) * t₂✝ }> / ρ ⟶ ?mult.inl.nat.inr.w / ?mult.inl.nat.inr.h.wmult.inl.nat.inr.h.w δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₂✝:Tmh₂:<{ ∅ / δ ⊢ t₂✝ ⦂ Nat }>ih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'n✝:Nath₁:<{ ∅ / δ ⊢ ~(Tm.const n✝) ⦂ Nat }>h₁_ih✝:∅ = ∅ → (Tm.const n✝).IsValue ∨ ∃ t' ρ', Tm.const n✝ / ρ ⟶ t' / ρ'hs₂✝:∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ't₂':Tmρ':Storehs₂:t₂✝ / ρ ⟶ t₂' / ρ'⊢ Storemult.inl.nat.inr.w δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₂✝:Tmh₂:<{ ∅ / δ ⊢ t₂✝ ⦂ Nat }>ih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'n✝:Nath₁:<{ ∅ / δ ⊢ ~(Tm.const n✝) ⦂ Nat }>h₁_ih✝:∅ = ∅ → (Tm.const n✝).IsValue ∨ ∃ t' ρ', Tm.const n✝ / ρ ⟶ t' / ρ'hs₂✝:∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ't₂':Tmρ':Storehs₂:t₂✝ / ρ ⟶ t₂' / ρ'⊢ Tm; solve_by_elim using StlcRefEval All goals completed! 🐙
| ite0 h₁ => ite0.inl δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₁✝:Tmt₂✝:Tmt₃✝:Tmτ✝:Tyh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ Nat }>h₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ τ✝ }>h₃✝:<{ ∅ / δ ⊢ t₃✝ ⦂ τ✝ }>h₁_ih✝:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'h₂_ih✝:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'h₃_ih✝:∅ = ∅ → t₃✝.IsValue ∨ ∃ t' ρ', t₃✝ / ρ ⟶ t' / ρ'hv:t₁✝.IsValue⊢ ∃ t' ρ', <{ if0 t₁✝ then t₂✝ else t₃✝ }> / ρ ⟶ t' / ρ'
cases hv with (inversion h₁ All goals completed! 🐙)
| nat n => const δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₂✝:Tmt₃✝:Tmτ✝:Tyh₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ τ✝ }>h₃✝:<{ ∅ / δ ⊢ t₃✝ ⦂ τ✝ }>h₂_ih✝:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'h₃_ih✝:∅ = ∅ → t₃✝.IsValue ∨ ∃ t' ρ', t₃✝ / ρ ⟶ t' / ρ'n:Nath₁_ih✝:∅ = ∅ → (Tm.const n).IsValue ∨ ∃ t' ρ', Tm.const n / ρ ⟶ t' / ρ'⊢ ∃ t' ρ', <{ if0 ~(Tm.const n) then t₂✝ else t₃✝ }> / ρ ⟶ t' / ρ'
cases n const.zero δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₂✝:Tmt₃✝:Tmτ✝:Tyh₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ τ✝ }>h₃✝:<{ ∅ / δ ⊢ t₃✝ ⦂ τ✝ }>h₂_ih✝:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'h₃_ih✝:∅ = ∅ → t₃✝.IsValue ∨ ∃ t' ρ', t₃✝ / ρ ⟶ t' / ρ'h₁_ih✝:∅ = ∅ → <{ 0 }>.IsValue ∨ ∃ t' ρ', <{ 0 }> / ρ ⟶ t' / ρ'⊢ ∃ t' ρ', <{ if0 0 then t₂✝ else t₃✝ }> / ρ ⟶ t' / ρ'const.succ δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₂✝:Tmt₃✝:Tmτ✝:Tyh₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ τ✝ }>h₃✝:<{ ∅ / δ ⊢ t₃✝ ⦂ τ✝ }>h₂_ih✝:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'h₃_ih✝:∅ = ∅ → t₃✝.IsValue ∨ ∃ t' ρ', t₃✝ / ρ ⟶ t' / ρ'n✝:Nath₁_ih✝:∅ = ∅ → (Tm.const (n✝ + 1)).IsValue ∨ ∃ t' ρ', Tm.const (n✝ + 1) / ρ ⟶ t' / ρ'⊢ ∃ t' ρ', <{ if0 ~(Tm.const (n✝ + 1)) then t₂✝ else t₃✝ }> / ρ ⟶ t' / ρ' <;> const.zero δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₂✝:Tmt₃✝:Tmτ✝:Tyh₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ τ✝ }>h₃✝:<{ ∅ / δ ⊢ t₃✝ ⦂ τ✝ }>h₂_ih✝:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'h₃_ih✝:∅ = ∅ → t₃✝.IsValue ∨ ∃ t' ρ', t₃✝ / ρ ⟶ t' / ρ'h₁_ih✝:∅ = ∅ → <{ 0 }>.IsValue ∨ ∃ t' ρ', <{ 0 }> / ρ ⟶ t' / ρ'⊢ ∃ t' ρ', <{ if0 0 then t₂✝ else t₃✝ }> / ρ ⟶ t' / ρ'const.succ δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₂✝:Tmt₃✝:Tmτ✝:Tyh₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ τ✝ }>h₃✝:<{ ∅ / δ ⊢ t₃✝ ⦂ τ✝ }>h₂_ih✝:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'h₃_ih✝:∅ = ∅ → t₃✝.IsValue ∨ ∃ t' ρ', t₃✝ / ρ ⟶ t' / ρ'n✝:Nath₁_ih✝:∅ = ∅ → (Tm.const (n✝ + 1)).IsValue ∨ ∃ t' ρ', Tm.const (n✝ + 1) / ρ ⟶ t' / ρ'⊢ ∃ t' ρ', <{ if0 ~(Tm.const (n✝ + 1)) then t₂✝ else t₃✝ }> / ρ ⟶ t' / ρ'
(apply Exists.intro const.succ.h δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₂✝:Tmt₃✝:Tmτ✝:Tyh₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ τ✝ }>h₃✝:<{ ∅ / δ ⊢ t₃✝ ⦂ τ✝ }>h₂_ih✝:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'h₃_ih✝:∅ = ∅ → t₃✝.IsValue ∨ ∃ t' ρ', t₃✝ / ρ ⟶ t' / ρ'n✝:Nath₁_ih✝:∅ = ∅ → (Tm.const (n✝ + 1)).IsValue ∨ ∃ t' ρ', Tm.const (n✝ + 1) / ρ ⟶ t' / ρ'⊢ ∃ ρ', <{ if0 ~(Tm.const (n✝ + 1)) then t₂✝ else t₃✝ }> / ρ ⟶ ?const.succ.w / ρ'const.succ.w δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₂✝:Tmt₃✝:Tmτ✝:Tyh₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ τ✝ }>h₃✝:<{ ∅ / δ ⊢ t₃✝ ⦂ τ✝ }>h₂_ih✝:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'h₃_ih✝:∅ = ∅ → t₃✝.IsValue ∨ ∃ t' ρ', t₃✝ / ρ ⟶ t' / ρ'n✝:Nath₁_ih✝:∅ = ∅ → (Tm.const (n✝ + 1)).IsValue ∨ ∃ t' ρ', Tm.const (n✝ + 1) / ρ ⟶ t' / ρ'⊢ Tm; apply Exists.intro const.succ.h.h δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₂✝:Tmt₃✝:Tmτ✝:Tyh₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ τ✝ }>h₃✝:<{ ∅ / δ ⊢ t₃✝ ⦂ τ✝ }>h₂_ih✝:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'h₃_ih✝:∅ = ∅ → t₃✝.IsValue ∨ ∃ t' ρ', t₃✝ / ρ ⟶ t' / ρ'n✝:Nath₁_ih✝:∅ = ∅ → (Tm.const (n✝ + 1)).IsValue ∨ ∃ t' ρ', Tm.const (n✝ + 1) / ρ ⟶ t' / ρ'⊢ <{ if0 ~(Tm.const (n✝ + 1)) then t₂✝ else t₃✝ }> / ρ ⟶ ?const.succ.w / ?const.succ.h.wconst.succ.h.w δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₂✝:Tmt₃✝:Tmτ✝:Tyh₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ τ✝ }>h₃✝:<{ ∅ / δ ⊢ t₃✝ ⦂ τ✝ }>h₂_ih✝:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'h₃_ih✝:∅ = ∅ → t₃✝.IsValue ∨ ∃ t' ρ', t₃✝ / ρ ⟶ t' / ρ'n✝:Nath₁_ih✝:∅ = ∅ → (Tm.const (n✝ + 1)).IsValue ∨ ∃ t' ρ', Tm.const (n✝ + 1) / ρ ⟶ t' / ρ'⊢ Storeconst.succ.w δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₂✝:Tmt₃✝:Tmτ✝:Tyh₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ τ✝ }>h₃✝:<{ ∅ / δ ⊢ t₃✝ ⦂ τ✝ }>h₂_ih✝:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'h₃_ih✝:∅ = ∅ → t₃✝.IsValue ∨ ∃ t' ρ', t₃✝ / ρ ⟶ t' / ρ'n✝:Nath₁_ih✝:∅ = ∅ → (Tm.const (n✝ + 1)).IsValue ∨ ∃ t' ρ', Tm.const (n✝ + 1) / ρ ⟶ t' / ρ'⊢ Tm; solve_by_elim using StlcRefEval All goals completed! 🐙)
| deref h => deref.inl δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₁✝:Tmτ₁✝:Tyh:<{ ∅ / δ ⊢ t₁✝ ⦂ Ref τ₁✝ }>h_ih✝:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'hv:t₁✝.IsValue⊢ ∃ t' ρ', <{ !t₁✝ }> / ρ ⟶ t' / ρ'
cases hv deref.inl.abs δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextτ₁✝:Tyx✝:Stringτ₂✝:Tyt₁✝:Tmh:<{ ∅ / δ ⊢ λ ~x✝ : τ₂✝ . t₁✝ ⦂ Ref τ₁✝ }>h_ih✝:∅ = ∅ → <{ λ ~x✝ : τ₂✝ . t₁✝ }>.IsValue ∨ ∃ t' ρ', <{ λ ~x✝ : τ₂✝ . t₁✝ }> / ρ ⟶ t' / ρ'⊢ ∃ t' ρ', <{ !(λ ~x✝ : τ₂✝ . t₁✝) }> / ρ ⟶ t' / ρ'deref.inl.nat δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextτ₁✝:Tyn✝:Nath:<{ ∅ / δ ⊢ ~(Tm.const n✝) ⦂ Ref τ₁✝ }>h_ih✝:∅ = ∅ → (Tm.const n✝).IsValue ∨ ∃ t' ρ', Tm.const n✝ / ρ ⟶ t' / ρ'⊢ ∃ t' ρ', <{ !~(Tm.const n✝) }> / ρ ⟶ t' / ρ'deref.inl.unit δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextτ₁✝:Tyh:<{ ∅ / δ ⊢ unit ⦂ Ref τ₁✝ }>h_ih✝:∅ = ∅ → <{ unit }>.IsValue ∨ ∃ t' ρ', <{ unit }> / ρ ⟶ t' / ρ'⊢ ∃ t' ρ', <{ !unit }> / ρ ⟶ t' / ρ'deref.inl.loc_ δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextτ₁✝:Tyl✝:Nath:<{ ∅ / δ ⊢ ~(Tm.loc l✝) ⦂ Ref τ₁✝ }>h_ih✝:∅ = ∅ → (Tm.loc l✝).IsValue ∨ ∃ t' ρ', Tm.loc l✝ / ρ ⟶ t' / ρ'⊢ ∃ t' ρ', <{ !~(Tm.loc l✝) }> / ρ ⟶ t' / ρ' <;> deref.inl.abs δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextτ₁✝:Tyx✝:Stringτ₂✝:Tyt₁✝:Tmh:<{ ∅ / δ ⊢ λ ~x✝ : τ₂✝ . t₁✝ ⦂ Ref τ₁✝ }>h_ih✝:∅ = ∅ → <{ λ ~x✝ : τ₂✝ . t₁✝ }>.IsValue ∨ ∃ t' ρ', <{ λ ~x✝ : τ₂✝ . t₁✝ }> / ρ ⟶ t' / ρ'⊢ ∃ t' ρ', <{ !(λ ~x✝ : τ₂✝ . t₁✝) }> / ρ ⟶ t' / ρ'deref.inl.nat δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextτ₁✝:Tyn✝:Nath:<{ ∅ / δ ⊢ ~(Tm.const n✝) ⦂ Ref τ₁✝ }>h_ih✝:∅ = ∅ → (Tm.const n✝).IsValue ∨ ∃ t' ρ', Tm.const n✝ / ρ ⟶ t' / ρ'⊢ ∃ t' ρ', <{ !~(Tm.const n✝) }> / ρ ⟶ t' / ρ'deref.inl.unit δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextτ₁✝:Tyh:<{ ∅ / δ ⊢ unit ⦂ Ref τ₁✝ }>h_ih✝:∅ = ∅ → <{ unit }>.IsValue ∨ ∃ t' ρ', <{ unit }> / ρ ⟶ t' / ρ'⊢ ∃ t' ρ', <{ !unit }> / ρ ⟶ t' / ρ'deref.inl.loc_ δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextτ₁✝:Tyl✝:Nath:<{ ∅ / δ ⊢ ~(Tm.loc l✝) ⦂ Ref τ₁✝ }>h_ih✝:∅ = ∅ → (Tm.loc l✝).IsValue ∨ ∃ t' ρ', Tm.loc l✝ / ρ ⟶ t' / ρ'⊢ ∃ t' ρ', <{ !~(Tm.loc l✝) }> / ρ ⟶ t' / ρ' inversion h loc_ δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextl✝:Nath_ih✝:∅ = ∅ → (Tm.loc l✝).IsValue ∨ ∃ t' ρ', Tm.loc l✝ / ρ ⟶ t' / ρ'h✝:l✝ < List.length δ⊢ ∃ t' ρ', <{ !~(Tm.loc l✝) }> / ρ ⟶ t' / ρ'
apply Exists.intro loc_.h δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextl✝:Nath_ih✝:∅ = ∅ → (Tm.loc l✝).IsValue ∨ ∃ t' ρ', Tm.loc l✝ / ρ ⟶ t' / ρ'h✝:l✝ < List.length δ⊢ ∃ ρ', <{ !~(Tm.loc l✝) }> / ρ ⟶ ?loc_.w / ρ'loc_.w δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextl✝:Nath_ih✝:∅ = ∅ → (Tm.loc l✝).IsValue ∨ ∃ t' ρ', Tm.loc l✝ / ρ ⟶ t' / ρ'h✝:l✝ < List.length δ⊢ Tm; apply Exists.intro loc_.h.h δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextl✝:Nath_ih✝:∅ = ∅ → (Tm.loc l✝).IsValue ∨ ∃ t' ρ', Tm.loc l✝ / ρ ⟶ t' / ρ'h✝:l✝ < List.length δ⊢ <{ !~(Tm.loc l✝) }> / ρ ⟶ ?loc_.w / ?loc_.h.wloc_.h.w δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextl✝:Nath_ih✝:∅ = ∅ → (Tm.loc l✝).IsValue ∨ ∃ t' ρ', Tm.loc l✝ / ρ ⟶ t' / ρ'h✝:l✝ < List.length δ⊢ Storeloc_.w δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextl✝:Nath_ih✝:∅ = ∅ → (Tm.loc l✝).IsValue ∨ ∃ t' ρ', Tm.loc l✝ / ρ ⟶ t' / ρ'h✝:l✝ < List.length δ⊢ Tm; apply Step.derefLoc loc_.h.h δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextl✝:Nath_ih✝:∅ = ∅ → (Tm.loc l✝).IsValue ∨ ∃ t' ρ', Tm.loc l✝ / ρ ⟶ t' / ρ'h✝:l✝ < List.length δ⊢ l✝ < List.length ρ; lia All goals completed! 🐙
| assign h₁ _ _ ih₂ => assign.inl δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₁✝:Tmt₂✝:Tmτ₂✝:Tyh₁:<{ ∅ / δ ⊢ t₁✝ ⦂ Ref τ₂✝ }>h₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ τ₂✝ }>h₁_ih✝:∅ = ∅ → t₁✝.IsValue ∨ ∃ t' ρ', t₁✝ / ρ ⟶ t' / ρ'ih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'hv:t₁✝.IsValue⊢ ∃ t' ρ', <{ t₁✝ := t₂✝ }> / ρ ⟶ t' / ρ'
cases hv assign.inl.abs δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₂✝:Tmτ₂✝¹:Tyh₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ τ₂✝ }>ih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'x✝:Stringτ₂✝:Tyt₁✝:Tmh₁:<{ ∅ / δ ⊢ λ ~x✝ : τ₂✝ . t₁✝ ⦂ Ref τ₂✝¹ }>h₁_ih✝:∅ = ∅ → <{ λ ~x✝ : τ₂✝ . t₁✝ }>.IsValue ∨ ∃ t' ρ', <{ λ ~x✝ : τ₂✝ . t₁✝ }> / ρ ⟶ t' / ρ'⊢ ∃ t' ρ', <{ (λ ~x✝ : τ₂✝ . t₁✝) := t₂✝ }> / ρ ⟶ t' / ρ'assign.inl.nat δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₂✝:Tmτ₂✝:Tyh₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ τ₂✝ }>ih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'n✝:Nath₁:<{ ∅ / δ ⊢ ~(Tm.const n✝) ⦂ Ref τ₂✝ }>h₁_ih✝:∅ = ∅ → (Tm.const n✝).IsValue ∨ ∃ t' ρ', Tm.const n✝ / ρ ⟶ t' / ρ'⊢ ∃ t' ρ', <{ ~(Tm.const n✝) := t₂✝ }> / ρ ⟶ t' / ρ'assign.inl.unit δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₂✝:Tmτ₂✝:Tyh₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ τ₂✝ }>ih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'h₁:<{ ∅ / δ ⊢ unit ⦂ Ref τ₂✝ }>h₁_ih✝:∅ = ∅ → <{ unit }>.IsValue ∨ ∃ t' ρ', <{ unit }> / ρ ⟶ t' / ρ'⊢ ∃ t' ρ', <{ unit := t₂✝ }> / ρ ⟶ t' / ρ'assign.inl.loc_ δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₂✝:Tmτ₂✝:Tyh₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ τ₂✝ }>ih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'l✝:Nath₁:<{ ∅ / δ ⊢ ~(Tm.loc l✝) ⦂ Ref τ₂✝ }>h₁_ih✝:∅ = ∅ → (Tm.loc l✝).IsValue ∨ ∃ t' ρ', Tm.loc l✝ / ρ ⟶ t' / ρ'⊢ ∃ t' ρ', <{ ~(Tm.loc l✝) := t₂✝ }> / ρ ⟶ t' / ρ' <;> assign.inl.abs δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₂✝:Tmτ₂✝¹:Tyh₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ τ₂✝ }>ih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'x✝:Stringτ₂✝:Tyt₁✝:Tmh₁:<{ ∅ / δ ⊢ λ ~x✝ : τ₂✝ . t₁✝ ⦂ Ref τ₂✝¹ }>h₁_ih✝:∅ = ∅ → <{ λ ~x✝ : τ₂✝ . t₁✝ }>.IsValue ∨ ∃ t' ρ', <{ λ ~x✝ : τ₂✝ . t₁✝ }> / ρ ⟶ t' / ρ'⊢ ∃ t' ρ', <{ (λ ~x✝ : τ₂✝ . t₁✝) := t₂✝ }> / ρ ⟶ t' / ρ'assign.inl.nat δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₂✝:Tmτ₂✝:Tyh₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ τ₂✝ }>ih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'n✝:Nath₁:<{ ∅ / δ ⊢ ~(Tm.const n✝) ⦂ Ref τ₂✝ }>h₁_ih✝:∅ = ∅ → (Tm.const n✝).IsValue ∨ ∃ t' ρ', Tm.const n✝ / ρ ⟶ t' / ρ'⊢ ∃ t' ρ', <{ ~(Tm.const n✝) := t₂✝ }> / ρ ⟶ t' / ρ'assign.inl.unit δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₂✝:Tmτ₂✝:Tyh₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ τ₂✝ }>ih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'h₁:<{ ∅ / δ ⊢ unit ⦂ Ref τ₂✝ }>h₁_ih✝:∅ = ∅ → <{ unit }>.IsValue ∨ ∃ t' ρ', <{ unit }> / ρ ⟶ t' / ρ'⊢ ∃ t' ρ', <{ unit := t₂✝ }> / ρ ⟶ t' / ρ'assign.inl.loc_ δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₂✝:Tmτ₂✝:Tyh₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ τ₂✝ }>ih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'l✝:Nath₁:<{ ∅ / δ ⊢ ~(Tm.loc l✝) ⦂ Ref τ₂✝ }>h₁_ih✝:∅ = ∅ → (Tm.loc l✝).IsValue ∨ ∃ t' ρ', Tm.loc l✝ / ρ ⟶ t' / ρ'⊢ ∃ t' ρ', <{ ~(Tm.loc l✝) := t₂✝ }> / ρ ⟶ t' / ρ' inversion h₁ loc_ δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₂✝:Tmih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'l✝:Nath₁_ih✝:∅ = ∅ → (Tm.loc l✝).IsValue ∨ ∃ t' ρ', Tm.loc l✝ / ρ ⟶ t' / ρ'h✝:l✝ < List.length δh₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ ~δ[l✝] }>⊢ ∃ t' ρ', <{ ~(Tm.loc l✝) := t₂✝ }> / ρ ⟶ t' / ρ'
cases ih₂ (by δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₂✝:Tmih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'l✝:Nath₁_ih✝:∅ = ∅ → (Tm.loc l✝).IsValue ∨ ∃ t' ρ', Tm.loc l✝ / ρ ⟶ t' / ρ'h✝:l✝ < List.length δh₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ ~δ[l✝] }>⊢ ∅ = ∅ rfl All goals completed! 🐙) with
| inl hv₂ => loc_.inl δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₂✝:Tmih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'l✝:Nath₁_ih✝:∅ = ∅ → (Tm.loc l✝).IsValue ∨ ∃ t' ρ', Tm.loc l✝ / ρ ⟶ t' / ρ'h✝:l✝ < List.length δh₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ ~δ[l✝] }>hv₂:t₂✝.IsValue⊢ ∃ t' ρ', <{ ~(Tm.loc l✝) := t₂✝ }> / ρ ⟶ t' / ρ'
apply Exists.intro loc_.inl.h δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₂✝:Tmih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'l✝:Nath₁_ih✝:∅ = ∅ → (Tm.loc l✝).IsValue ∨ ∃ t' ρ', Tm.loc l✝ / ρ ⟶ t' / ρ'h✝:l✝ < List.length δh₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ ~δ[l✝] }>hv₂:t₂✝.IsValue⊢ ∃ ρ', <{ ~(Tm.loc l✝) := t₂✝ }> / ρ ⟶ ?loc_.inl.w / ρ'loc_.inl.w δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₂✝:Tmih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'l✝:Nath₁_ih✝:∅ = ∅ → (Tm.loc l✝).IsValue ∨ ∃ t' ρ', Tm.loc l✝ / ρ ⟶ t' / ρ'h✝:l✝ < List.length δh₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ ~δ[l✝] }>hv₂:t₂✝.IsValue⊢ Tm; apply Exists.intro loc_.inl.h.h δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₂✝:Tmih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'l✝:Nath₁_ih✝:∅ = ∅ → (Tm.loc l✝).IsValue ∨ ∃ t' ρ', Tm.loc l✝ / ρ ⟶ t' / ρ'h✝:l✝ < List.length δh₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ ~δ[l✝] }>hv₂:t₂✝.IsValue⊢ <{ ~(Tm.loc l✝) := t₂✝ }> / ρ ⟶ ?loc_.inl.w / ?loc_.inl.h.wloc_.inl.h.w δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₂✝:Tmih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'l✝:Nath₁_ih✝:∅ = ∅ → (Tm.loc l✝).IsValue ∨ ∃ t' ρ', Tm.loc l✝ / ρ ⟶ t' / ρ'h✝:l✝ < List.length δh₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ ~δ[l✝] }>hv₂:t₂✝.IsValue⊢ Storeloc_.inl.w δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₂✝:Tmih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'l✝:Nath₁_ih✝:∅ = ∅ → (Tm.loc l✝).IsValue ∨ ∃ t' ρ', Tm.loc l✝ / ρ ⟶ t' / ρ'h✝:l✝ < List.length δh₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ ~δ[l✝] }>hv₂:t₂✝.IsValue⊢ Tm; apply Step.assign hv₂ loc_.inl.h.h δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₂✝:Tmih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'l✝:Nath₁_ih✝:∅ = ∅ → (Tm.loc l✝).IsValue ∨ ∃ t' ρ', Tm.loc l✝ / ρ ⟶ t' / ρ'h✝:l✝ < List.length δh₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ ~δ[l✝] }>hv₂:t₂✝.IsValue⊢ l✝ < List.length ρ; lia All goals completed! 🐙
| inr hs₂ => loc_.inr δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₂✝:Tmih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'l✝:Nath₁_ih✝:∅ = ∅ → (Tm.loc l✝).IsValue ∨ ∃ t' ρ', Tm.loc l✝ / ρ ⟶ t' / ρ'h✝:l✝ < List.length δh₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ ~δ[l✝] }>hs₂:∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'⊢ ∃ t' ρ', <{ ~(Tm.loc l✝) := t₂✝ }> / ρ ⟶ t' / ρ'
have ⟨t₂', ρ', hs₂⟩ := hs₂ loc_.inr δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₂✝:Tmih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'l✝:Nath₁_ih✝:∅ = ∅ → (Tm.loc l✝).IsValue ∨ ∃ t' ρ', Tm.loc l✝ / ρ ⟶ t' / ρ'h✝:l✝ < List.length δh₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ ~δ[l✝] }>hs₂✝:∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ't₂':Tmρ':Storehs₂:t₂✝ / ρ ⟶ t₂' / ρ'⊢ ∃ t' ρ', <{ ~(Tm.loc l✝) := t₂✝ }> / ρ ⟶ t' / ρ'
apply Exists.intro loc_.inr.h δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₂✝:Tmih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'l✝:Nath₁_ih✝:∅ = ∅ → (Tm.loc l✝).IsValue ∨ ∃ t' ρ', Tm.loc l✝ / ρ ⟶ t' / ρ'h✝:l✝ < List.length δh₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ ~δ[l✝] }>hs₂✝:∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ't₂':Tmρ':Storehs₂:t₂✝ / ρ ⟶ t₂' / ρ'⊢ ∃ ρ', <{ ~(Tm.loc l✝) := t₂✝ }> / ρ ⟶ ?loc_.inr.w / ρ'loc_.inr.w δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₂✝:Tmih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'l✝:Nath₁_ih✝:∅ = ∅ → (Tm.loc l✝).IsValue ∨ ∃ t' ρ', Tm.loc l✝ / ρ ⟶ t' / ρ'h✝:l✝ < List.length δh₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ ~δ[l✝] }>hs₂✝:∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ't₂':Tmρ':Storehs₂:t₂✝ / ρ ⟶ t₂' / ρ'⊢ Tm; apply Exists.intro loc_.inr.h.h δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₂✝:Tmih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'l✝:Nath₁_ih✝:∅ = ∅ → (Tm.loc l✝).IsValue ∨ ∃ t' ρ', Tm.loc l✝ / ρ ⟶ t' / ρ'h✝:l✝ < List.length δh₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ ~δ[l✝] }>hs₂✝:∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ't₂':Tmρ':Storehs₂:t₂✝ / ρ ⟶ t₂' / ρ'⊢ <{ ~(Tm.loc l✝) := t₂✝ }> / ρ ⟶ ?loc_.inr.w / ?loc_.inr.h.wloc_.inr.h.w δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₂✝:Tmih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'l✝:Nath₁_ih✝:∅ = ∅ → (Tm.loc l✝).IsValue ∨ ∃ t' ρ', Tm.loc l✝ / ρ ⟶ t' / ρ'h✝:l✝ < List.length δh₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ ~δ[l✝] }>hs₂✝:∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ't₂':Tmρ':Storehs₂:t₂✝ / ρ ⟶ t₂' / ρ'⊢ Storeloc_.inr.w δ:StoreTyt:Tmτ:Tyρ:StorehStoreTy:δ ⊢ ρhLen:List.length δ = List.length ρright✝:∀ (l : Nat), l < List.length ρ → <{ ∅ / δ ⊢ ~ρ[l] ⦂ ~δ[l] }>Γ:Contextt₂✝:Tmih₂:∅ = ∅ → t₂✝.IsValue ∨ ∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ'l✝:Nath₁_ih✝:∅ = ∅ → (Tm.loc l✝).IsValue ∨ ∃ t' ρ', Tm.loc l✝ / ρ ⟶ t' / ρ'h✝:l✝ < List.length δh₂✝:<{ ∅ / δ ⊢ t₂✝ ⦂ ~δ[l✝] }>hs₂✝:∃ t' ρ', t₂✝ / ρ ⟶ t' / ρ't₂':Tmρ':Storehs₂:t₂✝ / ρ ⟶ t₂' / ρ'⊢ Tm; solve_by_elim using StlcRefEval All goals completed! 🐙
9.6. References and Nontermination
An important fact about the STLC is that it is normalizing — that is, every well-typed term can be reduced to a value in a finite number of steps.
What about STLC + references? Surprisingly, adding references causes us to lose the normalization property: there exist well-typed terms in the STLC + references which can continue to reduce forever, without ever reaching a normal form!
How can we construct such a term? The main idea is to make a function which calls itself. We first make a function which calls another function stored in a reference cell; the trick is that we then smuggle in a reference to itself!
(λR: Ref (Unit → Unit),
R := (λx:Unit,(!R) unit); (!R) unit)
(ref (λX:Unit.unit))
First, ref (λX:Unit.unit) creates a reference to a cell of
type Unit → Unit. We then pass this reference as the argument
to a function which binds it to the name R, and assigns to it
the function λX:Unit.(!R) unit — that is, the function which
ignores its argument and calls the function stored in R on the
argument unit; but of course, that function is itself! To start
the divergent loop, we execute the function stored in the cell by
evaluating (!r) unit.
Here is the divergent term in Lean:
namespace RefsAndNontermination
def loop_fun := <{ λX : Unit. (!R) unit }>
def loop :=
<{ (λR : Ref (Unit → Unit). (( R := (λX : Unit. (!R) unit) ); ( (! R) unit ) ))
(ref (λX : Unit. unit)) }>
This term is well typed:
theorem loop_typeable : ∃ τ, <{ ∅ / [] ⊢ loop ⦂ τ }> := by ⊢ ∃ τ, <{ ∅ / [] ⊢ loop ⦂ τ }>
apply Exists.intro h ⊢ <{ ∅ / [] ⊢ loop ⦂ ~?w }>w ⊢ Ty
apply_rules using StlcRefTyping All goals completed! 🐙
To show formally that the term diverges, we first define the
step_closure of the single-step reduction relation, written
⟶+. This is just like the reflexive step closure of
single-step reduction (which we're been writing ⟶*), except
that it is not reflexive: t ⟶+ t' means that τ can reach
t' by one or more steps of reduction.
inductive StepClosure {X:Type} (R: Relation X) : X → X → Prop :=
| one {x y : X} (h₁ : R x y) : StepClosure R x y
| step {x y z : X} (h₁ : R x y) (h₂ : StepClosure R y z) : StepClosure R x z
scoped notation:40
t:71 " / " ρ:41 " ⟶+ " t':71 " / " ρ':41 =>
StepClosure Step (t, ρ) (t', ρ')
Now, we can show that the expression loop reduces to the
expression !(loc 0) unit and the size-one store
[R:=(loc 0)] loop_fun.
As a convenience, we introduce a slight variant of the normalize
tactic, called reduce, which tries solving the goal with
Multi.refl at each step, instead of waiting until the goal can't
be reduced any more. Of course, the whole point is that loop
doesn't normalize, so the old normalize tactic would just go
into an infinite loop reducing it forever!
syntax "reduce" " using " ident,+ : tactic
macro_rules
| `(tactic| reduce using $xs,*) =>
`(tactic|
repeat
(apply Multi.step
· solve_by_elim (maxDepth := 15) (constructor := false) [Nat.le.refl, Nat.le.step] using $xs,*
try apply Multi.refl))
Next, we use reduce to show that loop steps to
!(loc 0) unit, starting from the ∅ store.
theorem loop_steps_to_loop_fun :
loop / [] ⟶* <{ (! (loc 0)) unit }> / [<{ [R := loc 0] loop_fun }>] := by ⊢ loop / [] ⟶* <{ (!(loc 0)) unit }> / [<{ [R := loc 0] loop_fun }>]
reduce using StlcRefEval All goals completed! 🐙
Finally, we show that the latter expression reduces in two steps to itself!
theorem loop_fun_step_self :
<{ (! (loc 0)) unit }> / [<{ [R := loc 0] loop_fun }>] ⟶+
<{ (! (loc 0)) unit }> / [<{ [R := loc 0] loop_fun }>] := by ⊢ <{ (!(loc 0)) unit }> / [<{ [R := loc 0] loop_fun }>] ⟶+ <{ (!(loc 0)) unit }> / [<{ [R := loc 0] loop_fun }>]
apply StepClosure.step h₁ ⊢ Step (<{ (!(loc 0)) unit }>, [<{ [R := loc 0] loop_fun }>]) ?yh₂ ⊢ StepClosure Step ?y (<{ (!(loc 0)) unit }>, [<{ [R := loc 0] loop_fun }>])y ⊢ Tm × Store; solve_by_elim using StlcRefEval h₂ ⊢ <{ ~[<{ [R := loc 0] loop_fun }>][0] unit }> / [<{ [R := loc 0] loop_fun }>] ⟶+ <{ (!(loc 0)) unit }> /
[<{ [R := loc 0] loop_fun }>]
apply StepClosure.one h₂ ⊢ <{ ~[<{ [R := loc 0] loop_fun }>][0] unit }> / [<{ [R := loc 0] loop_fun }>] ⟶ <{ (!(loc 0)) unit }> /
[<{ [R := loc 0] loop_fun }>]; solve_by_elim using StlcRefEval All goals completed! 🐙
Use the above ideas to implement a factorial function in STLC with
references. (There is no need to prove formally that it really
behaves like the factorial. Just uncomment the example below to make
sure it gives the correct result when applied to the argument
4.)
def factorial : Tm :=
solution!(
<{(λR : (Ref (Nat → Nat) ).
(R := (λX : Nat. if0 X then 1 else (X * ( (!R) (pred X) ) ))); !R )
(ref (λX : Nat. X)) }>)
theorem factorial_type : <{ ∅ / [] ⊢ factorial ⦂ (Nat → Nat) }> := by ⊢ <{ ∅ / [] ⊢ factorial ⦂ Nat → Nat }>
solution!
apply_rules using StlcRefTyping All goals completed! 🐙
If your definition is correct, you should be able to finish
the example below; the proof should be fully
automatic using the reduce tactic, once the witness is supplied.
theorem factorial_4 : ∃ (ρ : Store), <{ factorial 4 }> / [] ⟶* .const 24 / ρ := by ⊢ ∃ ρ, <{ factorial 4 }> / [] ⟶* <{ 24 }> / ρ
solution!
exists [<{ λX : Nat. if0 X then 1 else (X * ((!(loc 0)) (pred X))) }>] ⊢ <{ factorial 4 }> / [] ⟶* <{ 24 }> / [<{ λ X : Nat . if0 X then 1 else X * (!(loc 0)) (pred X) }>]
reduce using StlcRefEval All goals completed! 🐙
end RefsAndNontermination
9.7. Additional Exercises
Challenge problem: modify our formalization to include an account of garbage collection, and prove that it satisfies whatever nice properties you can think to prove about it.
end STLCRef