mirror of
https://github.com/c-cube/sidekick.git
synced 2025-12-06 03:05:31 -05:00
perf(core): have eq and not_ be simplying
- `a=b` and `b=a` are now the same - `not (not u)` and `u` are now the same
This commit is contained in:
parent
9c57dad3f1
commit
0ff197d56c
1 changed files with 21 additions and 2 deletions
|
|
@ -68,9 +68,28 @@ let c_not store =
|
|||
let ty = arrow store b b in
|
||||
const store @@ Const.make C_not ops ~ty
|
||||
|
||||
let eq store a b = app_l store (c_eq store) [ ty a; a; b ]
|
||||
let eq store a b =
|
||||
if equal a b then
|
||||
true_ store
|
||||
else (
|
||||
let a, b =
|
||||
if compare a b <= 0 then
|
||||
a, b
|
||||
else
|
||||
b, a
|
||||
in
|
||||
app_l store (c_eq store) [ ty a; a; b ]
|
||||
)
|
||||
|
||||
let ite store a b c = app_l store (c_ite store) [ ty b; a; b; c ]
|
||||
let not store a = app store (c_not store) a
|
||||
|
||||
let not store a =
|
||||
(* turn [not (not u)] into [u] *)
|
||||
match view a with
|
||||
| E_app ({ view = E_const { c_view = C_not; _ }; _ }, u) -> u
|
||||
| E_const { c_view = C_true; _ } -> false_ store
|
||||
| E_const { c_view = C_false; _ } -> true_ store
|
||||
| _ -> app store (c_not store) a
|
||||
|
||||
let is_bool t =
|
||||
match view t with
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue