2023-08-25 16:28:58 +03:00
|
|
|
|
module Alias;
|
|
|
|
|
|
|
|
|
|
import Stdlib.Data.Fixity open;
|
|
|
|
|
|
|
|
|
|
-- aliases are allowed to forward reference
|
|
|
|
|
syntax alias Boolean := Bool;
|
|
|
|
|
syntax alias ⊥ := false;
|
|
|
|
|
syntax alias ⊤ := true;
|
|
|
|
|
|
|
|
|
|
--- Truth value
|
|
|
|
|
type Bool :=
|
|
|
|
|
| false
|
|
|
|
|
| true;
|
|
|
|
|
|
|
|
|
|
not : Boolean -> Boolean
|
|
|
|
|
| ⊥ := ⊤
|
|
|
|
|
| ⊤ := ⊥;
|
|
|
|
|
|
|
|
|
|
not2 (b : Boolean) : Boolean :=
|
|
|
|
|
let
|
|
|
|
|
syntax alias yes := ⊤;
|
|
|
|
|
syntax alias no := ⊥;
|
2023-10-31 20:36:34 +03:00
|
|
|
|
in case b of {
|
|
|
|
|
| no := yes
|
|
|
|
|
| yes := no
|
|
|
|
|
};
|
2023-08-25 16:28:58 +03:00
|
|
|
|
|
|
|
|
|
module ExportAlias;
|
|
|
|
|
syntax alias Binary := Bool;
|
|
|
|
|
syntax alias one := ⊤;
|
|
|
|
|
syntax alias zero := ⊥;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
open ExportAlias;
|
|
|
|
|
|
|
|
|
|
syntax operator || logical;
|
|
|
|
|
|| : Binary -> Binary -> Binary
|
|
|
|
|
| zero b := b
|
|
|
|
|
| one _ := one;
|
|
|
|
|
|
2023-09-26 12:28:50 +03:00
|
|
|
|
syntax operator or none;
|
2023-08-25 16:28:58 +03:00
|
|
|
|
syntax alias or := ||;
|
|
|
|
|
|
2023-09-26 12:28:50 +03:00
|
|
|
|
syntax alias ||| := ||;
|
|
|
|
|
|
2023-08-25 16:28:58 +03:00
|
|
|
|
or3 (a b c : Binary) : Binary := or (or a b) c;
|
|
|
|
|
|
2023-09-26 12:28:50 +03:00
|
|
|
|
or3' (a b c : Binary) : Binary := (a ||| b) ||| c;
|
|
|
|
|
|
2023-10-31 20:36:34 +03:00
|
|
|
|
type Pair := mkPair Binary Binary;
|
2023-08-25 16:28:58 +03:00
|
|
|
|
|
|
|
|
|
syntax operator , pair;
|
|
|
|
|
syntax alias , := mkPair;
|
|
|
|
|
|
|
|
|
|
myPair : Pair := one, ⊥;
|
|
|
|
|
|
|
|
|
|
localAlias : Binary -> Binary
|
|
|
|
|
| b :=
|
|
|
|
|
let
|
|
|
|
|
syntax alias b' := b;
|
|
|
|
|
in b';
|