This file proves that typechecking of .binaryApp .contains expressions is sound.
theorem
Cedar.Thm.type_of_contains_inversion
{x₁ x₂ : Spec.Expr}
{c c' : Validation.Capabilities}
{env : Validation.TypeEnv}
{ty : Validation.TypedExpr}
(h₁ : Validation.typeOf (Spec.Expr.binaryApp Spec.BinaryOp.contains x₁ x₂) c env = Except.ok (ty, c'))
:
c' = ∅ ∧ ty.typeOf = Validation.CedarType.bool Validation.BoolType.anyBool ∧ ∃ (ty₁ : Validation.CedarType), ∃ (ty₂ : Validation.CedarType), (ty₁ ⊔ ty₂).isSome = true ∧ (∃ (c₁ : Validation.Capabilities), (Validation.typeOf x₁ c env).typeOf = Except.ok (ty₁.set, c₁)) ∧ ∃ (c₂ : Validation.Capabilities), (Validation.typeOf x₂ c env).typeOf = Except.ok (ty₂, c₂)
theorem
Cedar.Thm.type_of_contains_is_sound
{x₁ x₂ : Spec.Expr}
{c₁ c₂ : Validation.Capabilities}
{env : Validation.TypeEnv}
{ty : Validation.TypedExpr}
{request : Spec.Request}
{entities : Spec.Entities}
(h₁ : CapabilitiesInvariant c₁ request entities)
(h₂ : InstanceOfWellFormedEnvironment request entities env)
(h₃ : Validation.typeOf (Spec.Expr.binaryApp Spec.BinaryOp.contains x₁ x₂) c₁ env = Except.ok (ty, c₂))
(ih₁ : TypeOfIsSound x₁)
(ih₂ : TypeOfIsSound x₂)
:
GuardedCapabilitiesInvariant (Spec.Expr.binaryApp Spec.BinaryOp.contains x₁ x₂) c₂ request entities ∧ ∃ (v : Spec.Value), EvaluatesTo (Spec.Expr.binaryApp Spec.BinaryOp.contains x₁ x₂) request entities v ∧ InstanceOfType env v ty.typeOf