Inductive my_type :=
| Type_pol : Z -> my_type
| Type_matrix : Z -> my_type.
Inductive redPair :=
| RedPair_interpretation : my_type -> redPair.
Inductive orderingProof :=
| OrderingProof_redPair : redPair -> orderingProof.
Inductive trsTerminationProof :=
| TrsTerminationProof_ruleRemoval :
orderingProof -> trsTerminationProof -> trsTerminationProof.
我想写一个
的函数Definition return_mytype (t : my_type) : option nat :=
match t with
| Type_pol _ => None
| Type_matrix i => Some (Z.to_nat i)
end.
Definition return_redPair (r : redPair ) : option nat :=
match r with
| RedPair_interpretation mty => return_mytype mty
end.
Definition return_orderProof (d : orderingProof) : option nat :=
match d with
| OrderingProof_redPair r => return_redPair r
end.
Definition return_trsTermProof (t : trsTerminationProof) : option nat :=
match t with
| TrsTerminationProof_ruleRemoval d _t => return_orderProof d
end.
我想编写函数return_trsTermProof
,该函数不仅可以参与d
,还可以使用例如t:trsTerminationProof
Fixpoint return_trsTermProof (t : trsTerminationProof) : option nat :=
match t with
| TrsTerminationProof_ruleRemoval d t =>
(* I don't know how can I take the function (return_orderProof d) *) ...
return_trsTermProof t
end.
答案 0 :(得分:2)
您的意思是,如果return_trsTermProof t_
返回return_orderProof d
,您想要返回none
吗?
Fixpoint return_trsTermProof (t : trsTerminationProof) : option nat :=
match t with
| TrsTerminationProof_ruleRemoval d t_ =>
match return_orderProof d with
| None => return_trsTermProof t_
| Some n => Some n
end
end.
如果你的归纳集没有任何构造函数,你也可以这样定义:
Fixpoint return_trsTermProof (t : trsTerminationProof) : option nat :=
match t with
| TrsTerminationProof_ruleRemoval (OrderingProof_redPair (RedPair_interpretation (Type_pol z))) t_ => return_trsTermProof t_
| TrsTerminationProof_ruleRemoval (OrderingProof_redPair (RedPair_interpretation (Type_matrix z))) t_ => Some (Z.to_nat z)
end.