XComposeAndNotations - rocq-prover/rocq GitHub Wiki
In Coq, you can use notations to have fancy (and/or more readable) way to write your code in Coq. Here is an example of what you can have:
Set Implicit Arguments.
Record set (A: Type): Type :=
Comprehension {In: A -> Prop}.
Delimit Scope set_scope with set.
Open Scope set_scope.
Notation "{ x : s '๏ฌ' P }" :=
({|In:=ฮป (x: s), P|}) (at level 10, x at level 69): set_scope.
Notation "{ x '๏ฌ' P }" := ({x:_ ๏ฌ P}) (at level 10, x at level 69): set_scope.
Notation "x โ X" := (X.(In) x) (at level 40): set_scope.
Notation "x โ X" := (ยฌ(x โ X)) (at level 40): set_scope.
Notation "X โ Y" := (โ x, x โ X โ x โ Y) (at level 40): set_scope.
Notation "X โก Y" := (XโY โง YโX) (at level 40): set_scope.
Notation "X โช Y" := ({x ๏ฌ x โ X โจ x โ Y}) (at level 55): set_scope.
Notation "X โฉ Y" := ({x ๏ฌ x โ X โง x โ Y}) (at level 50): set_scope.
Notation "โ X" := ({x ๏ฌ โ y, x โ y โง y โ X}) (at level 35): set_scope.
Notation "โ X" := ({x ๏ฌ โ y, y โ X โ x โ y}) (at level 30): set_scope.
Notation "f โปยน ฮฃ" := ({x ๏ฌ (f x) โ ฮฃ}) (at level 5): set_scope.
Notation "โ A" := ({x ๏ฌ x โ A}) (at level 5): set_scope.
Definition empty_set (A: Type) := {x: A ๏ฌ โฅ}.
Definition full_set (A: Type) := {x: A ๏ฌ โค}.
Notation "โ s" := (empty_set s) (at level 5): set_scope.
Notation "โ s" := (full_set s) (at level 5): set_scope.
Definition finite_union {A: Type} (f: nat -> set A) :=
fix finite_union n :=
match n with
| O => โA
| S k => (f k) โช (finite_union k)
end.
Axiom Extensionnality: โ (S: Type) (ฯ1 ฯ2: set S), ฯ1 โก ฯ2 โ ฯ1 = ฯ2.
Class Topology (S: Type): Type :=
{ O: set (set S);
Hempty: โS โ O;
Hall: โS โ O;
Hinter: โ ฯ1 ฯ2, (ฯ1 โ O) โ (ฯ2 โ O) โ (ฯ1 โฉ ฯ2) โ O;
HUNION: โ ฯs, (โ ฯ, (ฯ โ ฯs) โ (ฯ โ O)) โ (โฯs) โ O
}.
Definition Compact {A: Type} {ฮฉA: Topology A} a :=
โ os, (a โ โos โง (โ o, (o โ os) โ (o โ O))) โ
โ subos, โ n, (โ m, m<n โ (subos m) โ os) โง a โ (finite_union subos n).
Definition Separables {A: Type} {ฮฉA: Topology A} x y :=
โ ox, โ oy,
((y โ oy) โง (oy โ O)) โง
((x โ ox) โง (ox โ O)) โง
(ox โ โoy).
Lemma compacts_are_closed:
โ A {ฮฉA: Topology A}, (โ x y, x โ y โ Separables x y) โ
โ a, Compact a โ (โa โ O).
It seems cool, but how to have a way to input such a code in (almost) any editor under X? A good way is to have a "XIM" compliant editor (under X, almost any editor is XIM compliant; so it is the case for emacs, xterm, url in firefox, โฆ), then following some tutorials on XCompose, you can have some cool stuff:
echo 'GTK_IM_MODULE=xim' >> $PROFILE
echo 'QT_IM_MODULE=xim' >> $PROFILE
echo 'XMODIFIERS=@im=xim' >> $PROFILE
where $PROFILE is "/.profile" or "/.xinitrc" (or any script file run at logging time under X).
Now, if you do not have a "<Multi-key>", it can be (although not necessary) to define one:
echo 'keycode 117 = Multi_key' >> ~/.Xmodmap
To know the keycode you want, you can use xev.
Now create or edit "~/.XCompose" to have your wished compositions:
echo 'include "~/.XCompose.my_symbols"' >> ~/.XCompose
touch ~/.XCompose.my_symbols
Now, you have to edit this file to have your own compositions. Take a look at the official webpage of unicode to find the unicode codes you want.
The expected format is:
[non_empty_list_of_keys_or_unicode_name] : [optional """utf8-encoded-character"""] [optional unicode-name] [optional "U"unicode-code]
for instance:
echo '<Multi_key> <a> <l> <l> : "โ" U2200' >> ~/.XCompose.my_symbols
Finally restart your X server, and all should work.