Debian Codegraph @

theories/Ltac2/Bool.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 Require Import Ltac2.Init.
12
13 (** * Boolean operators *)
14
15 Ltac2 and x y :=
16 match x with
17 | true => y
18 | false => false
19 end.
20
21 Ltac2 or x y :=
22 match x with
23 | true => true
24 | false => y
25 end.
26
27 Ltac2 impl x y :=
28 match x with
29 | true => y
30 | false => true
31 end.
32
33 Ltac2 neg x :=
34 match x with
35 | true => false
36 | false => true
37 end.
38
39 Ltac2 xor x y :=
40 match x with
41 | true
42 => match y with
43 | true => false
44 | false => true
45 end
46 | false
47 => match y with
48 | true => true
49 | false => false
50 end
51 end.
52
53 Ltac2 equal x y :=
54 match x with
55 | true
56 => match y with
57 | true => true
58 | false => false
59 end
60 | false
61 => match y with
62 | true => false
63 | false => true
64 end
65 end.
66
67 (** * Boolean operators with lazy evaluation of the second argument *)
68
69 (** We place the notations in a separate module so that we can import them separately *)
70 Module Export BoolNotations.
71
72 Ltac2 Notation x(self) "&&" y(thunk(self)) : 2 :=
73 match x with
74 | true => y ()
75 | false => false
76 end.
77
78 Ltac2 Notation x(self) "||" y(thunk(self)) : 3 :=
79 match x with
80 | true => true
81 | false => y ()
82 end.
83
84 End BoolNotations.