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.

See this file for an example.

โš ๏ธ **GitHub.com Fallback** โš ๏ธ