Debian Codegraph @

test-suite/ssr/gen_have.v

raw
1 (************************************************************************)
2 (* * The Rocq Prover / The Rocq Development Team *)
3 (* v * Copyright INRIA, CNRS and contributors *)
4 (* <O___,, * (see version control and CREDITS file for authors & dates) *)
5 (* \VV/ **************************************************************)
6 (* // * This file is distributed under the terms of the *)
7 (* * GNU Lesser General Public License Version 2.1 *)
8 (* * (see LICENSE file for the text of the license) *)
9 (************************************************************************)
10
11 (* (c) Copyright 2006-2016 Microsoft Corporation and Inria. *)
12
13 Require Import ssreflect.
14 Require Import ssrfun ssrbool TestSuite.ssr_mini_mathcomp.
15 Axiom daemon : False. Ltac myadmit := case: daemon.
16
17 Axiom P : nat -> Prop.
18 Lemma clear_test (b1 b2 : bool) : b2 = b2.
19 Proof.
20 (* wlog gH : (b3 := b2) / b2 = b3. myadmit. *)
21 gen have {b1} H, gH : (b3 := b2) (w := erefl 3) / b2 = b3.
22 myadmit.
23 Fail exact (H b1).
24 exact (H b2 (erefl _)).
25 Qed.
26
27
28 Lemma test1 n (ngt0 : 0 < n) : P n.
29 gen have lt2le, /andP[H1 H2] : n ngt0 / (0 <= n) && (n != 0).
30 match goal with |- is_true((0 <= n) && (n != 0)) => myadmit end.
31 Check (lt2le : forall n : nat, 0 < n -> (0 <= n) && (n != 0)).
32 Check (H1 : 0 <= n).
33 Check (H2 : n != 0).
34 myadmit.
35 Qed.
36
37 Lemma test2 n (ngt0 : 0 < n) : P n.
38 gen have _, /andP[H1 H2] : n ngt0 / (0 <= n) && (n != 0).
39 match goal with |- is_true((0 <= n) && (n != 0)) => myadmit end.
40 lazymatch goal with
41 | lt2le : forall n : nat, is_true(0 < n) -> is_true((0 <= n) && (n != 0))
42 |- _ => fail "not cleared"
43 | _ => idtac end.
44 Check (H1 : 0 <= n).
45 Check (H2 : n != 0).
46 myadmit.
47 Qed.
48
49 Lemma test3 n (ngt0 : 0 < n) : P n.
50 gen have H : n ngt0 / (0 <= n) && (n != 0).
51 match goal with |- is_true((0 <= n) && (n != 0)) => myadmit end.
52 Check (H : forall n : nat, 0 < n -> (0 <= n) && (n != 0)).
53 myadmit.
54 Qed.
55
56 Lemma test4 n (ngt0 : 0 < n) : P n.
57 gen have : n ngt0 / (0 <= n) && (n != 0).
58 match goal with |- is_true((0 <= n) && (n != 0)) => myadmit end.
59 move=> H.
60 Check(H : forall n : nat, 0 < n -> (0 <= n) && (n != 0)).
61 myadmit.
62 Qed.
63
64 Lemma test4bis n (ngt0 : 0 < n) : P n.
65 wlog suff : n ngt0 / (0 <= n) && (n != 0); last first.
66 match goal with |- is_true((0 <= n) && (n != 0)) => myadmit end.
67 move=> H.
68 Check(H : forall n : nat, 0 < n -> (0 <= n) && (n != 0)).
69 myadmit.
70 Qed.
71
72 Lemma test5 n (ngt0 : 0 < n) : P n.
73 Fail gen have : / (0 <= n) && (n != 0).
74 Abort.
75
76 Lemma test6 n (ngt0 : 0 < n) : P n.
77 gen have : n ngt0 / (0 <= n) && (n != 0) by myadmit.
78 Abort.
79
80 Lemma test7 n (ngt0 : 0 < n) : P n.
81 Fail gen have : n / (0 <= n) && (n != 0).
82 Abort.
83
84 Lemma test3wlog2 n (ngt0 : 0 < n) : P n.
85 gen have H : (m := n) ngt0 / (0 <= m) && (m != 0).
86 match goal with
87 ngt0 : is_true(0 < m) |- is_true((0 <= m) && (m != 0)) => myadmit end.
88 Check (H : forall n : nat, 0 < n -> (0 <= n) && (n != 0)).
89 myadmit.
90 Qed.
91
92 Lemma test3wlog3 n (ngt0 : 0 < n) : P n.
93 gen have H : {n} (m := n) (n := 0) ngt0 / (0 <= m) && (m != n).
94 match goal with
95 ngt0 : is_true(n < m) |- is_true((0 <= m) && (m != n)) => myadmit end.
96 Check (H : forall m n : nat, n < m -> (0 <= m) && (m != n)).
97 myadmit.
98 Qed.
99
100 Lemma testw1 n (ngt0 : 0 < n) : n <= 0.
101 wlog H : (z := 0) (m := n) ngt0 / m != 0.
102 match goal with
103 |- (forall z m,
104 is_true(z < m) -> is_true(m != 0) -> is_true(m <= z)) ->
105 is_true(n <= 0) => myadmit end.
106 Check(n : nat).
107 Check(m : nat).
108 Check(z : nat).
109 Check(ngt0 : z < m).
110 Check(H : m != 0).
111 myadmit.
112 Qed.
113
114 Lemma testw2 n (ngt0 : 0 < n) : n <= 0.
115 wlog H : (m := n) (z := (X in n <= X)) ngt0 / m != z.
116 match goal with
117 |- (forall m z : nat,
118 is_true(0 < m) -> is_true(m != z) -> is_true(m <= z)) ->
119 is_true(n <= 0) => idtac end.
120 Restart.
121 wlog H : (m := n) (one := (X in X <= _)) ngt0 / m != one.
122 match goal with
123 |- (forall m one : nat,
124 is_true(one <= m) -> is_true(m != one) -> is_true(m <= 0)) ->
125 is_true(n <= 0) => idtac end.
126 Restart.
127 wlog H : {n} (m := n) (z := (X in _ <= X)) ngt0 / m != z.
128 match goal with
129 |- (forall m z : nat,
130 is_true(0 < z) -> is_true(m != z) -> is_true(m <= 0)) ->
131 is_true(n <= 0) => idtac end.
132 myadmit.
133 Fail Check n.
134 myadmit.
135 Qed.
136
137 Section Test.
138 Variable x : nat.
139 Definition addx y := y + x.
140
141 Lemma testw3 (m n : nat) (ngt0 : 0 < n) : n <= addx x.
142 wlog H : (n0 := n) (y := x) (@twoy := (id _ as X in _ <= X)) / twoy = 2 * y.
143 myadmit.
144 myadmit.
145 Qed.
146
147
148 Definition twox := x + x.
149 Definition bis := twox.
150
151 Lemma testw3x n (ngt0 : 0 < n) : n + x <= twox.
152 wlog H : (y := x) (@twoy := (X in _ <= X)) / twoy = 2 * y.
153 match goal with
154 |- (forall y : nat,
155 let twoy := y + y in
156 twoy = 2 * y -> is_true(n + y <= twoy)) ->
157 is_true(n + x <= twox) => myadmit end.
158 Restart.
159 wlog H : (y := x) (@twoy := (id _ as X in _ <= X)) / twoy = 2 * y.
160 match goal with
161 |- (forall y : nat,
162 let twoy := twox in
163 twoy = 2 * y -> is_true(n + y <= twoy)) ->
164 is_true(n + x <= twox) => myadmit end.
165 myadmit.
166 Qed.
167
168 End Test.
169
170 Lemma test_in n k (def_k : k = 0) (ngtk : k < n) : P n.
171 rewrite -(add0n n) in {def_k k ngtk} (m := k) (def_m := def_k) (ngtm := ngtk).
172 rewrite def_m add0n in {ngtm} (e := erefl 0 ) (ngt0 := ngtm) => {def_m}.
173 myadmit.
174 Qed.