我正试图做这门课程,被困了好几天。
我有一个数据类型电路,定义为
datatype "circuit" =
NOT "circuit"
| AND "circuit" "circuit"
| OR "circuit" "circuit"
| TRUE
| FALSE
| INPUT "int"
还有一个通过删除连续的非门来优化电路的功能,另一个功能是检查电路是否具有两个连续的非门。我需要写一个定理,证明一个函数被优化后,就不再包含两个连续的NOT门。这是我所拥有的:
fun opt_NOT where
"opt_NOT (NOT (NOT c)) = opt_NOT c"
| "opt_NOT (NOT c) = NOT (opt_NOT c)"
| "opt_NOT (AND c1 c2) = AND (opt_NOT c1) (opt_NOT c2)"
| "opt_NOT (OR c1 c2) = OR (opt_NOT c1) (opt_NOT c2)"
| "opt_NOT TRUE = TRUE"
| "opt_NOT FALSE = FALSE"
| "opt_NOT (INPUT i) = INPUT i"
fun check_NOT where
"check_NOT (NOT (NOT c) ) = True"
| "check_NOT (NOT (AND c1 c2)) = check_NOT (AND c1 c2) "
|"check_NOT (NOT (OR c1 c2)) = check_NOT (OR c1 c2)"
| " check_NOT TRUE = False "
| " check_NOT FALSE = False "
| "check_NOT (NOT TRUE ) = False"
|"check_NOT ( NOT FALSE ) = False"
|"check_NOT (INPUT i) = False "
|" check_NOT (NOT (INPUT i)) = False "
| "check_NOT (AND c1 c2) = (if check_NOT c1 = True then True
else if check_NOT c2 = True then True else False ) "
| " check_NOT (OR c1 c2) = (if check_NOT c1 = True then True
else if check_NOT c2 = True then True else False ) "
theorem "check_NOT (opt_NOT c) = False "
apply(induct rule: opt_NOT.induct)
apply auto
现在,在apply auto
之后,该定理只剩下一个子目标,即check_NOT c = False
。我知道,证明甚至不应该朝这个方向发展,以将其作为子目标。我尝试使用opt_NOT.induct
实例化opt_NOT.induct [of ]
,但没有成功。
我还有一个模拟功能:
fun simulate where
"simulate (AND c1 c2) ρ = ((simulate c1 ρ) \<and> (simulate c2 ρ))"
| "simulate (OR c1 c2) ρ = ((simulate c1 ρ) \<or> (simulate c2 ρ))"
| "simulate (NOT c) ρ = (\<not> (simulate c ρ))"
| "simulate TRUE ρ = True"
| "simulate FALSE ρ = False"
| "simulate (INPUT i) ρ = ρ i"