0
下面是一个简单类型系统:如何取代存在量化变量?
datatype type =
VoidType
| IntegerType
| RealType
| StringType
datatype val =
VoidVal
| IntegerVal int
| RealVal real
| StringVal string
fun type_of :: "val ⇒ type" where
"type_of (VoidVal) = VoidType"
| "type_of (IntegerVal _) = IntegerType"
| "type_of (RealVal _) = RealType"
| "type_of (StringVal _) = StringType"
与类型一致性关系:
inductive less_type :: "type ⇒ type ⇒ bool" (infix "<" 65) where
"IntegerType < RealType"
整型值可强制转换为对应的真实值:
inductive cast :: "val ⇒ val ⇒ bool" where
"cast (IntegerVal x) (RealVal x)"
我想证明以下引理。如果变量x
的类型符合RealType
,则存在具有类型RealType
的值y
,并且x
可以被铸造为y
。
lemma is_castable_to_real:
"type_of x < RealType ⟹ ∃y. type_of y = RealType ∧ cast x y"
apply (rule exI[of _ "RealVal v"])
我可以证明使用cases
战术通用引理:
lemma is_castable:
"type_of x < τ ⟹ ∃y. type_of y = τ ∧ cast x y"
by (cases x; cases τ; auto simp add: less_type.simps cast.simps)
但我想了解如何在引理治疗存在量词。所以我想为y
提供一个具体的例子RealVal v
:
type_of x < RealType ⟹ ∃v. type_of (RealVal v) = RealType ∧ cast x (RealVal v)
的问题是,我得到下面的命题,而不是:
type_of x < RealType ⟹ type_of (RealVal v) = RealType ∧ cast x (RealVal v)
又是什么样的变量v
的?它是普遍量化的变量吗?如何使它存在量化?
是其他公式的'P'和'Q'占位符吗?否则,引理是不可证明的。如果是这样,那么发布具体公式可能会有所帮助。特别是:'y'从哪里来?它出现在'P'还是'Q'? – peq
@peq我已经添加了一个更具体的例子。 – Denis