需要在Int.lt上找到正确的策略

时间:2016-08-23 01:33:11

标签: coq compcert

我有以下引理但无法证明:

services.ConfigureApplicationCookie(config =>
            {
                config.Events = new CookieAuthenticationEvents
                {
                    OnRedirectToLogin = ctx => {
                        if (ctx.Request.Path.StartsWithSegments("/api"))
                        {
                            ctx.Response.StatusCode = (int)HttpStatusCode.Unauthorized;
                        }
                        else {
                            ctx.Response.Redirect(ctx.RedirectUri);
                        }
                        return Task.FromResult(0);
                    }
                };
            });

我找到了平等的策略 (link) ,但无法找到lt / ltu或gt / gtu的那个:

Lemma my_comp2: forall i t:Z,
t<i -> Int.ltu (Int.repr i) (Int.repr t) = false.
Proof.
....

任何帮助将不胜感激!

谢谢,

1 个答案:

答案 0 :(得分:3)

这个引理无法证明,因为它是错误的。以下是wordsize = 8位的一个反例(我将把这些概括给你)。

我们来看i = 256t = 255。显然,引理的前提是正确的(t < i)。然后,(Int.repr i) = 0因为整数环绕。 (Int.repr t) = 255,因为在这种情况下没有溢出,但ltu将返回true上述值,而不是false作为引理说明。

Definition i := 256.
Definition t := 255.

Eval compute in ltu (repr i) (repr t).  (* returns true *)

<小时/>

至于定理eq_false,它与你的引理有很大的不同,因为xy属于int,而不属于Z

Check eq_false
 : forall x y : int, x <> y -> eq x y = false

希望这有帮助。