| 1 |
Module AppliedTermsPrinting. |
| 2 |
|
| 3 |
(* Test different printing paths for applied terms *) |
| 4 |
|
| 5 |
Module InferredGivenImplicit. |
| 6 |
Set Implicit Arguments. |
| 7 |
Set Maximal Implicit Insertion. |
| 8 |
|
| 9 |
Axiom p : forall A (a1 a2:A) B (b:B), a1 = a2 /\ b = b. |
| 10 |
|
| 11 |
Check p 0 0 true. |
| 12 |
(* p 0 0 true *) |
| 13 |
Check p 0 0. |
| 14 |
(* p 0 0 *) |
| 15 |
Check p 0. |
| 16 |
(* p 0 *) |
| 17 |
Check @p _ 0 0 bool. |
| 18 |
(* p 0 0 (B:=bool) *) |
| 19 |
Check p 0 0 (B:=bool). |
| 20 |
(* p 0 0 (B:=bool) *) |
| 21 |
Check @p nat. |
| 22 |
(* p (A:=nat) *) |
| 23 |
Check p (A:=nat). |
| 24 |
(* p (A:=nat) *) |
| 25 |
Check @p _ 0 0. |
| 26 |
(* @p nat 0 0 *) |
| 27 |
Check @p. |
| 28 |
(* @p *) |
| 29 |
|
| 30 |
Unset Printing Implicit Defensive. |
| 31 |
Check @p _ 0 0 bool. |
| 32 |
(* p 0 0 *) |
| 33 |
Check @p nat. |
| 34 |
(* p *) |
| 35 |
Set Printing Implicit Defensive. |
| 36 |
End InferredGivenImplicit. |
| 37 |
|
| 38 |
Module ManuallyGivenImplicit. |
| 39 |
Axiom p : forall {A} (a1 a2:A) {B} (b:B), a1 = a2 /\ b = b. |
| 40 |
|
| 41 |
Check p 0 0 true. |
| 42 |
(* p 0 0 true *) |
| 43 |
Check p 0 0. |
| 44 |
(* p 0 0 *) |
| 45 |
Check p 0. |
| 46 |
(* p 0 *) |
| 47 |
Check @p _ 0 0 bool. |
| 48 |
(* p 0 0 *) |
| 49 |
Check p 0 0 (B:=bool). |
| 50 |
(* p 0 0 *) |
| 51 |
Check @p nat. |
| 52 |
(* p *) |
| 53 |
Check p (A:=nat). |
| 54 |
(* p *) |
| 55 |
Check @p _ 0 0. |
| 56 |
(* @p nat 0 0 *) |
| 57 |
Check @p. |
| 58 |
(* @p *) |
| 59 |
|
| 60 |
End ManuallyGivenImplicit. |
| 61 |
|
| 62 |
Module ProjectionWithImplicits. |
| 63 |
Set Implicit Arguments. |
| 64 |
Set Maximal Implicit Insertion. |
| 65 |
|
| 66 |
Record T {A} (a1 a2:A) := { f : forall B (b:B), a1 = a2 /\ b = b }. |
| 67 |
Parameter x : T 0 0. |
| 68 |
Check f x true. |
| 69 |
(* f x true *) |
| 70 |
Check @f _ _ _ x bool. |
| 71 |
(* f x (B:=bool) *) |
| 72 |
Check f x (B:=bool). |
| 73 |
(* f x (B:=bool) *) |
| 74 |
Check @f nat. |
| 75 |
(* @f nat *) |
| 76 |
Check @f _ 0 0. |
| 77 |
(* f (a1:=0) (a2:=0) *) |
| 78 |
Check f (a1:=0) (a2:=0). |
| 79 |
(* f (a1:=0) (a2:=0) *) |
| 80 |
Check @f. |
| 81 |
(* @f *) |
| 82 |
|
| 83 |
Unset Printing Implicit Defensive. |
| 84 |
Check f (a1:=0) (a2:=0). |
| 85 |
(* f *) |
| 86 |
Set Printing Implicit Defensive. |
| 87 |
|
| 88 |
Set Printing Projections. |
| 89 |
|
| 90 |
Check x.(f) true. |
| 91 |
(* x.(f) true *) |
| 92 |
Check x.(@f _ _ _) bool. |
| 93 |
(* x.(f) (B:=bool) *) |
| 94 |
Check x.(f) (B:=bool). |
| 95 |
(* x.(f) (B:=bool) *) |
| 96 |
Check @f nat. |
| 97 |
(* @f nat *) |
| 98 |
Check @f _ 0 0. |
| 99 |
(* f (a1:=0) (a2:=0) *) |
| 100 |
Check f (a1:=0) (a2:=0). |
| 101 |
(* f (a1:=0) (a2:=0) *) |
| 102 |
Check @f. |
| 103 |
(* @f *) |
| 104 |
|
| 105 |
Unset Printing Implicit Defensive. |
| 106 |
Check f (a1:=0) (a2:=0). |
| 107 |
(* f *) |
| 108 |
|
| 109 |
End ProjectionWithImplicits. |
| 110 |
|
| 111 |
Module AtAbbreviationForApplicationHead. |
| 112 |
|
| 113 |
Axiom p : forall {A} (a1 a2:A) {B} (b:B), a1 = a2 /\ b = b. |
| 114 |
|
| 115 |
Abbreviation u := @p. |
| 116 |
|
| 117 |
Check u _. |
| 118 |
(* u ?A *) |
| 119 |
Check p. |
| 120 |
(* u ?A *) |
| 121 |
Check @p. |
| 122 |
(* u *) |
| 123 |
Check u. |
| 124 |
(* u *) |
| 125 |
Check p 0 0. |
| 126 |
(* u nat 0 0 ?B *) |
| 127 |
Check u nat 0 0 bool. |
| 128 |
(* u nat 0 0 bool *) |
| 129 |
Check u nat 0 0. |
| 130 |
(* u nat 0 0 *) |
| 131 |
Check @p nat 0 0. |
| 132 |
(* u nat 0 0 *) |
| 133 |
|
| 134 |
End AtAbbreviationForApplicationHead. |
| 135 |
|
| 136 |
Module AbbreviationForApplicationHead. |
| 137 |
|
| 138 |
Set Implicit Arguments. |
| 139 |
Set Maximal Implicit Insertion. |
| 140 |
|
| 141 |
Axiom p : forall A (a1 a2:A) B (b:B), a1 = a2 /\ b = b. |
| 142 |
|
| 143 |
Abbreviation u := p. |
| 144 |
|
| 145 |
Check p. |
| 146 |
(* u *) |
| 147 |
Check @p. |
| 148 |
(* @u *) |
| 149 |
Check @u. |
| 150 |
(* @u *) |
| 151 |
Check u. |
| 152 |
(* u *) |
| 153 |
Check p 0 0. |
| 154 |
(* u 0 0 *) |
| 155 |
Check u 0 0. |
| 156 |
(* u 0 0 *) |
| 157 |
Check @p nat 0 0. |
| 158 |
(* @u nat 0 0 *) |
| 159 |
Check @u nat 0 0. |
| 160 |
(* @u nat 0 0 *) |
| 161 |
Check p 0 0 true. |
| 162 |
(* u 0 0 true *) |
| 163 |
Check u 0 0 true. |
| 164 |
(* u 0 0 true *) |
| 165 |
|
| 166 |
End AbbreviationForApplicationHead. |
| 167 |
|
| 168 |
Module AtAbbreviationForPartialApplication. |
| 169 |
|
| 170 |
Set Implicit Arguments. |
| 171 |
Set Maximal Implicit Insertion. |
| 172 |
|
| 173 |
Axiom p : forall A (a1 a2:A) B (b:B), a1 = a2 /\ b = b. |
| 174 |
|
| 175 |
Abbreviation v := (@p _ 0). |
| 176 |
|
| 177 |
Check v. |
| 178 |
(* v *) |
| 179 |
Check p 0 0. |
| 180 |
(* v 0 *) |
| 181 |
Check v 0. |
| 182 |
(* v 0 *) |
| 183 |
Check v 0 true. |
| 184 |
(* v 0 true *) |
| 185 |
Check @p nat 0. |
| 186 |
(* v *) |
| 187 |
Check @p nat 0 0. |
| 188 |
(* @v 0 *) |
| 189 |
Check @v 0. |
| 190 |
(* @v 0 *) |
| 191 |
Check @p nat 0 0 bool. |
| 192 |
(* v 0 *) |
| 193 |
Eval simpl in (fun x => _:nat) (@p nat 0 0 bool). |
| 194 |
(* ?n@{x:=v 0 (B:=bool)} *) |
| 195 |
|
| 196 |
End AtAbbreviationForPartialApplication. |
| 197 |
|
| 198 |
Module AbbreviationForPartialApplication. |
| 199 |
|
| 200 |
Set Implicit Arguments. |
| 201 |
Set Maximal Implicit Insertion. |
| 202 |
|
| 203 |
Axiom p : forall A (a1 a2:A) B (b:B), a1 = a2 /\ b = b. |
| 204 |
|
| 205 |
Abbreviation v := (p 0). |
| 206 |
|
| 207 |
Check v. |
| 208 |
(* v *) |
| 209 |
Check p 0 0. |
| 210 |
(* v 0 *) |
| 211 |
Check v 0. |
| 212 |
(* v 0 *) |
| 213 |
Check v 0 true. |
| 214 |
(* v 0 true *) |
| 215 |
Check @p nat 0. |
| 216 |
(* v *) |
| 217 |
Check @p nat 0 0. |
| 218 |
(* @v 0 *) |
| 219 |
Check @v 0. |
| 220 |
(* @v 0 *) |
| 221 |
Check @p nat 0 0 bool. |
| 222 |
(* v 0 *) |
| 223 |
Eval simpl in (fun x => _:nat) (@p nat 0 0 bool). |
| 224 |
(* ?n@{x:=v 0 (B:=bool)} *) |
| 225 |
|
| 226 |
End AbbreviationForPartialApplication. |
| 227 |
|
| 228 |
Module NotationForHeadApplication. |
| 229 |
|
| 230 |
Set Implicit Arguments. |
| 231 |
Set Maximal Implicit Insertion. |
| 232 |
|
| 233 |
Axiom p : forall A (a1 a2:A) B (b:B), a1 = a2 /\ b = b. |
| 234 |
|
| 235 |
Notation "##" := p (at level 0). |
| 236 |
|
| 237 |
Check p. |
| 238 |
(* ## *) |
| 239 |
Check ##. |
| 240 |
(* ## *) |
| 241 |
Check p 0. |
| 242 |
(* ## 0 *) |
| 243 |
Check ## 0. |
| 244 |
(* ## 0 *) |
| 245 |
Check p 0 0. |
| 246 |
(* ## 0 0 *) |
| 247 |
Check ## 0 0. |
| 248 |
(* ## 0 0 *) |
| 249 |
Check p 0 0 true. |
| 250 |
(* ## 0 0 true *) |
| 251 |
Check ## 0 0 true. |
| 252 |
(* ## 0 0 true *) |
| 253 |
Check p 0 0 (B:=bool). |
| 254 |
(* ## 0 0 *) |
| 255 |
Check ## 0 0 (B:=bool). |
| 256 |
(* ## 0 0 *) |
| 257 |
Eval simpl in (fun x => _:nat) (@p nat 0 0 bool). |
| 258 |
(* ?n@{x:=## 0 0 (B:=bool)} *) |
| 259 |
|
| 260 |
End NotationForHeadApplication. |
| 261 |
|
| 262 |
Module AtNotationForHeadApplication. |
| 263 |
|
| 264 |
Set Implicit Arguments. |
| 265 |
Set Maximal Implicit Insertion. |
| 266 |
|
| 267 |
Axiom p : forall A (a1 a2:A) B (b:B), a1 = a2 /\ b = b. |
| 268 |
|
| 269 |
Notation "##" := @p (at level 0). |
| 270 |
|
| 271 |
Check p. |
| 272 |
(* ## ?A *) |
| 273 |
Check @p. |
| 274 |
(* ## *) |
| 275 |
Check ##. |
| 276 |
(* ## *) |
| 277 |
Check p 0. |
| 278 |
(* ## nat 0 *) |
| 279 |
Check ## nat 0. |
| 280 |
(* ## nat 0 *) |
| 281 |
Check ## nat 0 0. |
| 282 |
(* ## nat 0 0 *) |
| 283 |
Check p 0 0. |
| 284 |
(* ## nat 0 0 ?B *) |
| 285 |
Check ## nat 0 0 _. |
| 286 |
(* ## nat 0 0 ?B *) |
| 287 |
Check ## nat 0 0 bool. |
| 288 |
(* ## nat 0 0 bool *) |
| 289 |
Check ## nat 0 0 bool true. |
| 290 |
(* ## nat 0 0 bool true *) |
| 291 |
|
| 292 |
End AtNotationForHeadApplication. |
| 293 |
|
| 294 |
Module NotationForPartialApplication. |
| 295 |
|
| 296 |
Set Implicit Arguments. |
| 297 |
Set Maximal Implicit Insertion. |
| 298 |
|
| 299 |
Axiom p : forall A (a1 a2:A) B (b:B), a1 = a2 /\ b = b. |
| 300 |
|
| 301 |
Notation "## q" := (p q) (at level 2, q at level 0). |
| 302 |
|
| 303 |
Check p 0. |
| 304 |
(* ## 0 *) |
| 305 |
Check ## 0. |
| 306 |
(* ## 0 *) |
| 307 |
Check ## 0 0. |
| 308 |
(* ## 0 0 *) |
| 309 |
Check p 0 0 (B:=bool). |
| 310 |
(* ## 0 0 *) |
| 311 |
Check ## 0 0 (B:=bool). |
| 312 |
(* ## 0 0 *) |
| 313 |
Eval simpl in (fun x => _:nat) (## 0 0 (B:=bool)). |
| 314 |
(* ?n@{## 0 0 (B:=bool)} *) |
| 315 |
Check p 0 0 true. |
| 316 |
(* ## 0 0 true *) |
| 317 |
Check ## 0 0 true. |
| 318 |
(* ## 0 0 true *) |
| 319 |
|
| 320 |
End NotationForPartialApplication. |
| 321 |
|
| 322 |
Module AtNotationForPartialApplication. |
| 323 |
|
| 324 |
Set Implicit Arguments. |
| 325 |
Set Maximal Implicit Insertion. |
| 326 |
|
| 327 |
Axiom p : forall A (a1 a2:A) B (b:B), a1 = a2 /\ b = b. |
| 328 |
|
| 329 |
Notation "## q" := (@p _ q) (at level 2, q at level 0). |
| 330 |
|
| 331 |
Check p 0. |
| 332 |
(* ## 0 *) |
| 333 |
Check ## 0. |
| 334 |
(* ## 0 *) |
| 335 |
Check ## 0 0. |
| 336 |
(* ## 0 0 *) |
| 337 |
Check p 0 0 (B:=bool). |
| 338 |
(* ## 0 0 *) |
| 339 |
Check ## 0 0 (B:=bool). |
| 340 |
(* ## 0 0 *) |
| 341 |
Eval simpl in (fun x => _:nat) (## 0 0 (B:=bool)). |
| 342 |
(* ?n@{## 0 0 (B:=bool)} *) |
| 343 |
Check p 0 0 true. |
| 344 |
(* ## 0 0 true *) |
| 345 |
Check ## 0 0 true. |
| 346 |
(* ## 0 0 true *) |
| 347 |
|
| 348 |
End AtNotationForPartialApplication. |
| 349 |
|
| 350 |
End AppliedTermsPrinting. |
| 351 |
|
| 352 |
Module AppliedPatternsPrinting. |
| 353 |
|
| 354 |
(* Other tests testing inheritance of scope and implicit in |
| 355 |
term and pattern for parsing and printing *) |
| 356 |
|
| 357 |
Inductive T := p (a:nat) (b:bool) {B} (b:B) : T. |
| 358 |
Notation "0" := true : bool_scope. |
| 359 |
|
| 360 |
Module A. |
| 361 |
Notation "#" := @p (at level 0). |
| 362 |
Check # 0 0 _ true. |
| 363 |
Check fun a => match a with # 0 0 _ _ => 1 | _ => 2 end. (* !! *) |
| 364 |
End A. |
| 365 |
|
| 366 |
Module B. |
| 367 |
Notation "#'" := p (at level 0). |
| 368 |
Check #' 0 0 true. |
| 369 |
Check fun a => match a with #' 0 0 _ => 1 | _ => 2 end. |
| 370 |
End B. |
| 371 |
|
| 372 |
Module C. |
| 373 |
Notation "## q" := (@p q) (at level 2, q at level 0). |
| 374 |
Check ## 0 0 true. |
| 375 |
Check fun a => match a with ## 0 0 _ => 1 | _ => 2 end. |
| 376 |
End C. |
| 377 |
|
| 378 |
Module D. |
| 379 |
Notation "##' q" := (p q) (at level 2, q at level 0). |
| 380 |
Check ##' 0 0 true. |
| 381 |
Check fun a => match a with ##' 0 0 _ => 1 | _ => 2 end. |
| 382 |
End D. |
| 383 |
|
| 384 |
Module E. |
| 385 |
Abbreviation P := @ p. |
| 386 |
Check P 0 0 _ true. |
| 387 |
Check fun a => match a with P 0 0 _ _ => 1 | _ => 2 end. |
| 388 |
End E. |
| 389 |
|
| 390 |
Module F. |
| 391 |
Abbreviation P' := p. |
| 392 |
Check P' 0 0 true. |
| 393 |
Check fun a => match a with P' 0 0 _ => 1 | _ => 2 end. |
| 394 |
End F. |
| 395 |
|
| 396 |
Module G. |
| 397 |
Abbreviation Q q := (@p q). |
| 398 |
Check Q 0 0 true. |
| 399 |
Check fun a => match a with Q 0 0 _ => 1 | _ => 2 end. |
| 400 |
End G. |
| 401 |
|
| 402 |
Module H. |
| 403 |
Abbreviation Q' q := (p q). |
| 404 |
Check Q' 0 0 true. |
| 405 |
Check fun a => match a with Q' 0 0 _ => 1 | _ => 2 end. |
| 406 |
End H. |
| 407 |
|
| 408 |
End AppliedPatternsPrinting. |
| 409 |
|
| 410 |
Module Activation0. |
| 411 |
Module Activation. |
| 412 |
|
| 413 |
Disable Notation "_ + _" : nat_scope. |
| 414 |
Check Nat.add 0 0. |
| 415 |
Fail Check 0 + 0. |
| 416 |
|
| 417 |
Disable Notation "_ + _" : type_scope. |
| 418 |
Fail Check 0 + 0. |
| 419 |
|
| 420 |
Abbreviation f x := (Some x). |
| 421 |
|
| 422 |
Disable Notation f. |
| 423 |
|
| 424 |
Check Some 0. |
| 425 |
Fail Check f 0. |
| 426 |
|
| 427 |
End Activation. |
| 428 |
End Activation0. |
| 429 |
|
| 430 |
Module Activation1. |
| 431 |
Import Activation0. |
| 432 |
|
| 433 |
Check Nat.add 0 0. |
| 434 |
Check 0 + 0. |
| 435 |
|
| 436 |
Import Activation. |
| 437 |
Check Nat.add 0 0. |
| 438 |
Fail Check 0 + 0. |
| 439 |
End Activation1. |