Plain-language statement
If an expression is well-typed according to the typechecker, and the input environment and capabilities satisfy some invariants, then either (1) evaluation produces a value of the returned type or (2) it returns an error of type entityDoesNotExist, extensionError, or arithBoundsError. Both options are encoded in the EvaluatesTo predicate.
Exact Lean statement
theorem type_of_is_sound {e : Expr} {c₁ c₂ : Capabilities} {env : TypeEnv} {ty : TypedExpr} {request : Request} {entities : Entities} :
CapabilitiesInvariant c₁ request entities →
InstanceOfWellFormedEnvironment request entities env →
typeOf e c₁ env = .ok (ty, c₂) →
GuardedCapabilitiesInvariant e c₂ request entities ∧
∃ (v : Value), EvaluatesTo e request entities v ∧ InstanceOfType env v ty.typeOfFormal artifact
Lean source
theorem type_of_is_sound {e : Expr} {c₁ c₂ : Capabilities} {env : TypeEnv} {ty : TypedExpr} {request : Request} {entities : Entities} : CapabilitiesInvariant c₁ request entities → InstanceOfWellFormedEnvironment request entities env → typeOf e c₁ env = .ok (ty, c₂) → GuardedCapabilitiesInvariant e c₂ request entities ∧ ∃ (v : Value), EvaluatesTo e request entities v ∧ InstanceOfType env v ty.typeOf:= by intro h₁ h₂ h₃ match e with | .lit l => exact type_of_lit_is_sound h₃ | .var var => exact type_of_var_is_sound h₂ h₃ | .ite x₁ x₂ x₃ => have ih₁ := @type_of_is_sound x₁ have ih₂ := @type_of_is_sound x₂ have ih₃ := @type_of_is_sound x₃ exact type_of_ite_is_sound h₁ h₂ h₃ ih₁ ih₂ ih₃ | .and x₁ x₂ => have ih₁ := @type_of_is_sound x₁ have ih₂ := @type_of_is_sound x₂ exact type_of_and_is_sound h₁ h₂ h₃ ih₁ ih₂ | .or x₁ x₂ => have ih₁ := @type_of_is_sound x₁ have ih₂ := @type_of_is_sound x₂ exact type_of_or_is_sound h₁ h₂ h₃ ih₁ ih₂ | .unaryApp op₁ x₁ => have ih := @type_of_is_sound x₁ exact type_of_unaryApp_is_sound h₁ h₂ h₃ ih | .binaryApp op₂ x₁ x₂ => have ih₁ := @type_of_is_sound x₁ have ih₂ := @type_of_is_sound x₂ exact type_of_binaryApp_is_sound h₁ h₂ h₃ ih₁ ih₂ | .hasAttr x₁ a => have ih := @type_of_is_sound x₁ exact type_of_hasAttr_is_sound h₁ h₂ h₃ ih | .getAttr x₁ a => have ih := @type_of_is_sound x₁ exact type_of_getAttr_is_sound h₁ h₂ h₃ ih | .set xs => have ih : ∀ xᵢ, xᵢ ∈ xs → TypeOfIsSound xᵢ := by intro xᵢ _ exact @type_of_is_sound xᵢ exact type_of_set_is_sound h₁ h₂ h₃ ih | .record axs => have ih : ∀ axᵢ, axᵢ ∈ axs → TypeOfIsSound axᵢ.snd := by intro axᵢ hᵢ have _ : sizeOf axᵢ.snd < 1 + sizeOf axs := by apply List.sizeOf_snd_lt_sizeOf_list hᵢ exact @type_of_is_sound axᵢ.snd exact type_of_record_is_sound h₁ h₂ h₃ ih | .call xfn xs => have ih : ∀ xᵢ, xᵢ ∈ xs → TypeOfIsSound xᵢ := by intro xᵢ _ exact @type_of_is_sound xᵢ exact type_of_call_is_sound h₁ h₂ h₃ ih- Project
- Cedar Specification
- License
- Apache-2.0
- Commit
- 3f093947b8ae
- Source
- cedar-lean/Cedar/Thm/Validation/Typechecker.lean:50-103
Reuse this declaration
Bring the exact result into your workflow
The import identifies the source module. Your project still needs the pinned package dependency shown on this page.
What this badge means
This completion status comes from the project or community source. It has not yet been represented here as an independent rebuild and axiom audit.
Continue in this project
Related declarations
Find? ext
Cedar.Data.Map.find?_ext
Plain-language statement
Two well-formed maps are equal if they have the same find? for every key.
Source project: Cedar Specification
Person-level attribution pending.
Find? notmem keys
Cedar.Data.Map.find?_notmem_keys
Plain-language statement
Inverse of find?_mem_toList, except that this requires wf
Source project: Cedar Specification
Person-level attribution pending.
Find? some iff in values
Cedar.Data.Map.find?_some_iff_in_values
Plain-language statement
The mp direction of this does not need the wf precondition and, in fact, is available separately as find?_some_implies_in_values above
Source project: Cedar Specification
Person-level attribution pending.