Skip to content

Commit 163f496

Browse files
authored
add binary integers (#1)
1 parent a0f2296 commit 163f496

File tree

5 files changed

+1317
-12
lines changed

5 files changed

+1317
-12
lines changed

Comp.lp

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
/* Comparison datatype
2+
3+
By Quentin Garchery (May 2021). */
4+
5+
require open Blanqui.Lib.Set Blanqui.Lib.Prop Blanqui.Lib.FOL Blanqui.Lib.Eq
6+
Blanqui.Lib.Bool;
7+
8+
inductive Comp : TYPE
9+
| Eq : Comp
10+
| Lt : Comp
11+
| Gt : Comp;
12+
13+
// set code for Comp
14+
15+
constant symbol comp : Set;
16+
17+
rule τ compComp;
18+
19+
// Boolean functions for testing head constructor
20+
21+
symbol isEq : Comp → 𝔹;
22+
23+
rule isEq Eqtrue
24+
with isEq Ltfalse
25+
with isEq Gtfalse;
26+
27+
symbol isLt : Comp → 𝔹;
28+
29+
rule isLt Eqfalse
30+
with isLt Lttrue
31+
with isLt Gtfalse;
32+
33+
symbol isGt : Comp → 𝔹;
34+
35+
rule isGt Eqfalse
36+
with isGt Ltfalse
37+
with isGt Gttrue;
38+
39+
// Discriminate constructors
40+
41+
symbol LtEq : π (LtEq) ≔
42+
begin
43+
assume h; refine ind_eq hn, istrue(isEq n)) top
44+
end;
45+
46+
symbol GtEq : π (GtEq) ≔
47+
begin
48+
assume h; refine ind_eq hn, istrue(isEq n)) top
49+
end;
50+
51+
symbol GtLt : π (GtLt) ≔
52+
begin
53+
assume h; refine ind_eq hn, istrue(isLt n)) top
54+
end;
55+
56+
// Opposite of a Comp
57+
58+
symbol opp : CompComp;
59+
60+
rule opp EqEq
61+
with opp LtGt
62+
with opp GtLt;
63+
64+
symbol opp_idem c : π (opp (opp c) = c) ≔
65+
begin
66+
induction { reflexivity; } { reflexivity; } { reflexivity; }
67+
end;
68+
69+
// Conditional
70+
71+
symbol case_Comp [A] : Comp → τ A → τ A → τ A → τ A;
72+
73+
rule case_Comp Eq $x _ _ ↪ $x
74+
with case_Comp Lt _ $x _ ↪ $x
75+
with case_Comp Gt _ _ $x ↪ $x;

0 commit comments

Comments
 (0)