@@ -133,53 +133,6 @@ theorem type_of_neg_is_sound {x₁ : Expr} {c₁ c₂ : Capabilities} {env : Env
133133 exact type_is_inhabited CedarType.int
134134 }
135135
136- theorem type_of_mulBy_inversion {x₁ : Expr} {k : Int64} {c₁ c₂ : Capabilities} {env : Environment} {ty : CedarType}
137- (h₁ : typeOf (Expr.unaryApp (.mulBy k) x₁) c₁ env = Except.ok (ty, c₂)) :
138- c₂ = ∅ ∧
139- ty = .int ∧
140- ∃ c₁', typeOf x₁ c₁ env = Except.ok (.int, c₁')
141- := by
142- simp [typeOf] at h₁
143- cases h₂ : typeOf x₁ c₁ env <;> simp [h₂] at h₁
144- case ok res =>
145- have ⟨ty₁, c₁'⟩ := res
146- simp [typeOfUnaryApp] at h₁
147- split at h₁ <;> try contradiction
148- simp [ok] at h₁
149- simp [h₁]
150-
151- theorem type_of_mulBy_is_sound {x₁ : Expr} {k : Int64} {c₁ c₂ : Capabilities} {env : Environment} {ty : CedarType} {request : Request} {entities : Entities}
152- (h₁ : CapabilitiesInvariant c₁ request entities)
153- (h₂ : RequestAndEntitiesMatchEnvironment env request entities)
154- (h₃ : typeOf (Expr.unaryApp (.mulBy k) x₁) c₁ env = Except.ok (ty, c₂))
155- (ih : TypeOfIsSound x₁) :
156- GuardedCapabilitiesInvariant (Expr.unaryApp (.mulBy k) x₁) c₂ request entities ∧
157- ∃ v, EvaluatesTo (Expr.unaryApp (.mulBy k) x₁) request entities v ∧ InstanceOfType v ty
158- := by
159- have ⟨h₅, h₆, c₁', h₄⟩ := type_of_mulBy_inversion h₃
160- subst h₅; subst h₆
161- apply And.intro
162- case left => exact empty_guarded_capabilities_invariant
163- case right =>
164- have ⟨_, v₁, h₆, h₇⟩ := ih h₁ h₂ h₄ -- IH
165- simp [EvaluatesTo] at h₆
166- simp [EvaluatesTo, evaluate]
167- rcases h₆ with h₆ | h₆ | h₆ | h₆ <;> simp [h₆]
168- case inr.inr.inr =>
169- have ⟨i, h₈⟩ := instance_of_int_is_int h₇
170- subst h₈
171- simp [apply₁, intOrErr]
172- cases h₉ : k.mul? i
173- case none =>
174- simp only [or_false, or_true, true_and]
175- exact type_is_inhabited CedarType.int
176- case some i' =>
177- simp only [Except.ok.injEq, false_or, exists_eq_left']
178- apply InstanceOfType.instance_of_int
179- all_goals {
180- exact type_is_inhabited CedarType.int
181- }
182-
183136theorem type_of_like_inversion {x₁ : Expr} {p : Pattern} {c₁ c₂ : Capabilities} {env : Environment} {ty : CedarType}
184137 (h₁ : typeOf (Expr.unaryApp (.like p) x₁) c₁ env = Except.ok (ty, c₂)) :
185138 c₂ = ∅ ∧
@@ -234,7 +187,7 @@ theorem type_of_is_inversion {x₁ : Expr} {ety : EntityType} {c₁ c₂ : Capab
234187 have ⟨ty₁, c₁'⟩ := res
235188 simp [typeOfUnaryApp] at h₁
236189 split at h₁ <;> try contradiction
237- case h_5 _ _ ety' h₃ =>
190+ case h_4 _ _ ety' h₃ =>
238191 simp only [UnaryOp.is.injEq] at h₃
239192 subst h₃
240193 simp [ok] at h₁
@@ -284,7 +237,6 @@ theorem type_of_unaryApp_is_sound {op₁ : UnaryOp} {x₁ : Expr} {c₁ c₂ : C
284237 match op₁ with
285238 | .not => exact type_of_not_is_sound h₁ h₂ h₃ ih
286239 | .neg => exact type_of_neg_is_sound h₁ h₂ h₃ ih
287- | .mulBy k => exact type_of_mulBy_is_sound h₁ h₂ h₃ ih
288240 | .like p => exact type_of_like_is_sound h₁ h₂ h₃ ih
289241 | .is ety => exact type_of_is_is_sound h₁ h₂ h₃ ih
290242
0 commit comments