| 1 |
Require Import Ltac2.Ltac2. |
| 2 |
Require Import Ltac2.Bool. |
| 3 |
|
| 4 |
|
| 5 |
(** * Lazy eval tests *) |
| 6 |
|
| 7 |
Require Import Ltac2.Notations. |
| 8 |
|
| 9 |
(** ** Lazy and tests *) |
| 10 |
|
| 11 |
Example lazy_and_true_true : exists n, n=1. |
| 12 |
Proof. |
| 13 |
exists ltac2:(let val:= if (true && true) then '1 else '0 in exact $val). |
| 14 |
reflexivity. |
| 15 |
Qed. |
| 16 |
|
| 17 |
Example lazy_and_true_false : exists n, n=0. |
| 18 |
Proof. |
| 19 |
exists ltac2:(let val:= if (true && false) then '1 else '0 in exact $val). |
| 20 |
reflexivity. |
| 21 |
Qed. |
| 22 |
|
| 23 |
Example lazy_and_false_throw : exists n, n=0. |
| 24 |
Proof. |
| 25 |
exists ltac2:(let val:= if (false && Control.throw_invalid_argument "bad") then '1 else '0 in exact $val). |
| 26 |
reflexivity. |
| 27 |
Qed. |
| 28 |
|
| 29 |
Example lazy_and_true_true_true : exists n, n=1. |
| 30 |
Proof. |
| 31 |
exists ltac2:(let val:= if (true && true && true) then '1 else '0 in exact $val). |
| 32 |
reflexivity. |
| 33 |
Qed. |
| 34 |
|
| 35 |
Example lazy_and_true_false_throw : exists n, n=0. |
| 36 |
Proof. |
| 37 |
exists ltac2:(let val:= if (true && false && Control.throw_invalid_argument "bad") then '1 else '0 in exact $val). |
| 38 |
reflexivity. |
| 39 |
Qed. |
| 40 |
|
| 41 |
Example lazy_and_false_throw_throw : exists n, n=0. |
| 42 |
Proof. |
| 43 |
(* This shows that && is left recursive *) |
| 44 |
exists ltac2:(let val:= if (false && Control.throw_invalid_argument "bad" && Control.throw_invalid_argument "bad") then '1 else '0 in exact $val). |
| 45 |
reflexivity. |
| 46 |
Qed. |
| 47 |
|
| 48 |
Example lazy_and_fun_arg : exists n, n=1. |
| 49 |
Proof. |
| 50 |
exists ltac2:(let val:= if (Bool.equal true true && Bool.equal false false) then '1 else '0 in exact $val). |
| 51 |
reflexivity. |
| 52 |
Qed. |
| 53 |
|
| 54 |
(** ** Lazy or tests *) |
| 55 |
|
| 56 |
Example lazy_or_false_false : exists n, n=0. |
| 57 |
Proof. |
| 58 |
exists ltac2:(let val:= if (false || false) then '1 else '0 in exact $val). |
| 59 |
reflexivity. |
| 60 |
Qed. |
| 61 |
|
| 62 |
Example lazy_or_false_true : exists n, n=1. |
| 63 |
Proof. |
| 64 |
exists ltac2:(let val:= if (false || true) then '1 else '0 in exact $val). |
| 65 |
reflexivity. |
| 66 |
Qed. |
| 67 |
|
| 68 |
Example lazy_or_true_throw : exists n, n=1. |
| 69 |
Proof. |
| 70 |
exists ltac2:(let val:= if (true || Control.throw_invalid_argument "bad") then '1 else '0 in exact $val). |
| 71 |
reflexivity. |
| 72 |
Qed. |
| 73 |
|
| 74 |
Example lazy_or_false_false_false : exists n, n=0. |
| 75 |
Proof. |
| 76 |
exists ltac2:(let val:= if (false || false || false) then '1 else '0 in exact $val). |
| 77 |
reflexivity. |
| 78 |
Qed. |
| 79 |
|
| 80 |
Example lazy_or_false_true_throw : exists n, n=1. |
| 81 |
Proof. |
| 82 |
exists ltac2:(let val:= if (false || true || Control.throw_invalid_argument "bad") then '1 else '0 in exact $val). |
| 83 |
reflexivity. |
| 84 |
Qed. |
| 85 |
|
| 86 |
Example lazy_or_true_throw_throw : exists n, n=1. |
| 87 |
Proof. |
| 88 |
exists ltac2:(let val:= if (true || Control.throw_invalid_argument "bad" || Control.throw_invalid_argument "bad") then '1 else '0 in exact $val). |
| 89 |
reflexivity. |
| 90 |
Qed. |
| 91 |
|
| 92 |
Example lazy_or_fun_arg : exists n, n=1. |
| 93 |
Proof. |
| 94 |
exists ltac2:(let val:= if (Bool.equal true true || Bool.equal true false) then '1 else '0 in exact $val). |
| 95 |
reflexivity. |
| 96 |
Qed. |
| 97 |
|
| 98 |
(** ** Lazy or with and tests *) |
| 99 |
|
| 100 |
Example lazy_or_and_true_true_true : exists n, n=1. |
| 101 |
Proof. |
| 102 |
exists ltac2:(let val:= if (true || true && true) then '1 else '0 in exact $val). |
| 103 |
reflexivity. |
| 104 |
Qed. |
| 105 |
|
| 106 |
Example lazy_or_and_true_true_false : exists n, n=1. |
| 107 |
Proof. |
| 108 |
exists ltac2:(let val:= if (true || true && false) then '1 else '0 in exact $val). |
| 109 |
reflexivity. |
| 110 |
Qed. |
| 111 |
|
| 112 |
Example lazy_or_and_true_false_true : exists n, n=1. |
| 113 |
Proof. |
| 114 |
exists ltac2:(let val:= if (true || false && true) then '1 else '0 in exact $val). |
| 115 |
reflexivity. |
| 116 |
Qed. |
| 117 |
|
| 118 |
Example lazy_or_and_true_false_false : exists n, n=1. |
| 119 |
Proof. |
| 120 |
exists ltac2:(let val:= if (true || false && false) then '1 else '0 in exact $val). |
| 121 |
reflexivity. |
| 122 |
Qed. |
| 123 |
|
| 124 |
Example lazy_or_and_false_true_true : exists n, n=1. |
| 125 |
Proof. |
| 126 |
exists ltac2:(let val:= if (false || true && true) then '1 else '0 in exact $val). |
| 127 |
reflexivity. |
| 128 |
Qed. |
| 129 |
|
| 130 |
Example lazy_or_and_false_true_false : exists n, n=0. |
| 131 |
Proof. |
| 132 |
exists ltac2:(let val:= if (false || true && false) then '1 else '0 in exact $val). |
| 133 |
reflexivity. |
| 134 |
Qed. |
| 135 |
|
| 136 |
Example lazy_or_and_false_false_true : exists n, n=0. |
| 137 |
Proof. |
| 138 |
exists ltac2:(let val:= if (false || false && true) then '1 else '0 in exact $val). |
| 139 |
reflexivity. |
| 140 |
Qed. |
| 141 |
|
| 142 |
Example lazy_or_and_false_false_false : exists n, n=0. |
| 143 |
Proof. |
| 144 |
exists ltac2:(let val:= if (false || false && false) then '1 else '0 in exact $val). |
| 145 |
reflexivity. |
| 146 |
Qed. |
| 147 |
|
| 148 |
(* Lazy and with or tests *) |
| 149 |
|
| 150 |
Example lazy_and_or_true_true_true : exists n, n=1. |
| 151 |
Proof. |
| 152 |
exists ltac2:(let val:= if (true && true || true) then '1 else '0 in exact $val). |
| 153 |
reflexivity. |
| 154 |
Qed. |
| 155 |
|
| 156 |
Example lazy_and_or_true_true_false : exists n, n=1. |
| 157 |
Proof. |
| 158 |
exists ltac2:(let val:= if (true && true || false) then '1 else '0 in exact $val). |
| 159 |
reflexivity. |
| 160 |
Qed. |
| 161 |
|
| 162 |
Example lazy_and_or_true_false_true : exists n, n=1. |
| 163 |
Proof. |
| 164 |
exists ltac2:(let val:= if (true && false || true) then '1 else '0 in exact $val). |
| 165 |
reflexivity. |
| 166 |
Qed. |
| 167 |
|
| 168 |
Example lazy_and_or_true_false_false : exists n, n=0. |
| 169 |
Proof. |
| 170 |
exists ltac2:(let val:= if (true && false || false) then '1 else '0 in exact $val). |
| 171 |
reflexivity. |
| 172 |
Qed. |
| 173 |
|
| 174 |
Example lazy_and_or_false_true_true : exists n, n=1. |
| 175 |
Proof. |
| 176 |
exists ltac2:(let val:= if (false && true || true) then '1 else '0 in exact $val). |
| 177 |
reflexivity. |
| 178 |
Qed. |
| 179 |
|
| 180 |
Example lazy_and_or_false_true_false : exists n, n=0. |
| 181 |
Proof. |
| 182 |
exists ltac2:(let val:= if (false && true || false) then '1 else '0 in exact $val). |
| 183 |
reflexivity. |
| 184 |
Qed. |
| 185 |
|
| 186 |
Example lazy_and_or_false_false_true : exists n, n=1. |
| 187 |
Proof. |
| 188 |
exists ltac2:(let val:= if (false && false || true) then '1 else '0 in exact $val). |
| 189 |
reflexivity. |
| 190 |
Qed. |
| 191 |
|
| 192 |
Example lazy_and_or_false_false_false : exists n, n=0. |
| 193 |
Proof. |
| 194 |
exists ltac2:(let val:= if (false && false || false) then '1 else '0 in exact $val). |
| 195 |
reflexivity. |
| 196 |
Qed. |
| 197 |
|
| 198 |
(** * if then else tests *) |
| 199 |
|
| 200 |
(* these tests are from teh time when if was a notation, but it doesn't hurt to keep them *) |
| 201 |
|
| 202 |
Example if_then_else_true : exists n, n=1. |
| 203 |
Proof. |
| 204 |
exists ltac2:(let val:=if true then '1 else '0 in exact $val). |
| 205 |
reflexivity. |
| 206 |
Qed. |
| 207 |
|
| 208 |
Example if_then_else_false : exists n, n=0. |
| 209 |
Proof. |
| 210 |
exists ltac2:(let val:=if false then '1 else '0 in exact $val). |
| 211 |
reflexivity. |
| 212 |
Qed. |
| 213 |
|
| 214 |
Example if_then_else_nested_true : exists n, n=2. |
| 215 |
Proof. |
| 216 |
exists ltac2:(let val:=if true then if true then '2 else '1 else '0 in exact $val). |
| 217 |
reflexivity. |
| 218 |
Qed. |
| 219 |
|
| 220 |
Example if_then_else_nested_false : exists n, n=0. |
| 221 |
Proof. |
| 222 |
exists ltac2:(let val:=if false then '2 else if false then '1 else '0 in exact $val). |
| 223 |
reflexivity. |
| 224 |
Qed. |
| 225 |
|
| 226 |
Example if_then_else_match_cond : exists n, n=0. |
| 227 |
Proof. |
| 228 |
exists ltac2:(let val:=if match true with true => false | false => true end then '1 else '0 in exact $val). |
| 229 |
reflexivity. |
| 230 |
Qed. |
| 231 |
|
| 232 |
Example if_then_else_match_true : exists n, n=2. |
| 233 |
Proof. |
| 234 |
exists ltac2:(let val:=if true then match true with true => '2 | false => '1 end else '0 in exact $val). |
| 235 |
reflexivity. |
| 236 |
Qed. |
| 237 |
|
| 238 |
Example if_then_else_match_false : exists n, n=0. |
| 239 |
Proof. |
| 240 |
exists ltac2:(let val:=if false then '2 else match false with true => '1 | false => '0 end in exact $val). |
| 241 |
reflexivity. |
| 242 |
Qed. |
| 243 |
|
| 244 |
Example if_then_else_lazy_and : exists n, n=1. |
| 245 |
Proof. |
| 246 |
exists ltac2:(let val:=if true && true then '1 else '0 in exact $val). |
| 247 |
reflexivity. |
| 248 |
Qed. |
| 249 |
|
| 250 |
Example if_then_else_lazy_or : exists n, n=1. |
| 251 |
Proof. |
| 252 |
exists ltac2:(let val:=if true || true then '1 else '0 in exact $val). |
| 253 |
reflexivity. |
| 254 |
Qed. |