Coq 有没有什么策略可以证明这个看似简单的目标?
我有以下目标: 1子目标 ______________________________________(1/1) (如果(a=?a)%string | | false那么#a::nil else nil)=nil 因为显然是a=a,我想知道为什么策略“simple”不起作用Coq 有没有什么策略可以证明这个看似简单的目标?,coq,Coq,我有以下目标: 1子目标 ______________________________________(1/1) (如果(a=?a)%string | | false那么#a::nil else nil)=nil 因为显然是a=a,我想知道为什么策略“simple”不起作用 Print "=?". String.eqb = fix eqb (s1 s2 : string) {struct s1} : bool := match s1 with | "" => match s2
Print "=?".
String.eqb =
fix eqb (s1 s2 : string) {struct s1} : bool :=
match s1 with
| "" => match s2 with
| "" => true
| String _ _ => false
end
| String c1 s1' =>
match s2 with
| "" => false
| String c2 s2' => if Ascii.eqb c1 c2 then eqb s1' s2' else false
end
end
: string -> string -> bool
String.eqb
定义为fix
,这意味着如果Coq看不到参数的头符号(构造函数),Coq不会将其应用减少到参数中。在这种情况下,siml
策略无法应用String.eqb a a
,因为a
是一个变量,我们对其“形状”一无所知,因此您什么也看不到
顺便说一句,|
,即orb
函数是通过其第一个参数的模式匹配来定义的,因此simple
不能将(a=?a)%string | false
减少为(a=?a)%string
这里的一个解决方法是使用String.eqb\u refl
引理重写,使用这个引理后,很明显,除非上下文中存在矛盾,否则目标是不可证明的,在这种情况下,您实际上不需要String.eqb\u refl