Kind
TODO
match
, is it a judgement a : A
or a test that one is divisible by another (quotient is equal to zero) a / b
, one (string) is contained by another (regex) a β b? Proof searchMap
Xor
ignore
combinatorComparisons
| regular expressions /
set theory | linear logic | repr | type theory /
category theory | len | process calculus | probability theory /
learning theory | quantum theory |
| - | - | - | - | - | - | - | - |
| a β L (match) | | | a : A (judgement) | |
| $β
$ | $0$ | | | | nil, STOP |
| | $β€$ | True | | | |
| a | a | One(Seq(a)) | | len(a) | (sequential composition, prefix) |
| $Ξ΅$ (empty) β {Ξ΅} | $1$ | Seq([]) | * : 1 | 0 | SKIP |
| . | | Interval(MIN, MAX) | | 1 |
| ab / $a Β· b$ (concatenation) | $a β b$ (multiplicative conjunction/times) | Mul(a, b) | $a β b$ (tensor product) | len(a) + len(b) | P \|\|\| Q (interleaving) |
| a\|b (alternation),
$a βͺ b$ (union) | $a β b$ (additive disjuction/plus) | Or(a, b) | $a + b$ (coproduct) | max(len(a), len(b)) | (deterministic choice) |
| a* (kleen star),
..\|aa\|a\|Ξ΅ | $!a$ (exponential conjunction/of course),
Ξ½X.1 & a & (X β X) | Inf(a) | Ξ½, fixed point/trace, comonad, final coalgebra | | (replication) |
| a*? (non greedy),
Ξ΅\|a\|aa\|.. | $?a$ (exponential disjunction/why not),
$Β΅X.β₯ β a β (X β
X)$ | Sup(a) | ΞΌ, monad, initial algebra | |
| a? | a + 1 | Or(Zero, a) | |
| a{n,m} (repetition) | a | Or(Mul(a, Mul(a, ..)), Or(..)) | |
| [a-z] (class) | | Interval(a, z) | | |
| [^a-z]
(negation) | TODO this is complementary op | Neg(a)
/-a
| | |
| aβ (reverse) | right law vs left law | a.rev() | | len(a) |
| $a / b$ (right quotient) | $a βΈ b$ | Div(a, b) | | len(a) - len(b) | (hiding) |
| a \ b (left quotient) | | Div(a, b)
| | | (hiding) |
| RegexSet | a β
b (multiplicative disjunction/par) | Add(a, b) | $a β b$ (direct sum) | | (nondeterministic choice) |
| $a β© b$ (intersection) | a & b (additive conjunction/with) | And(a, b) | $a Γ b$ (product) | | (interface parallel) |
| a(?=b)
(positive lookahead) | | And(a, b) | | |
| a(?!b)
(negative lookahead) | | And(a, Not(b)) | | |
| (?<=a)b
(positive lookbehind) | | And(a, b) | | |
| (?<!a)b
(negative lookbehind) | | And(a, b) | | |
| $a β b, a β€ b$ (containmemt) | $a β€ b (β a = b β
a < b)$ | a.le(b) |
| | aβ₯ (dual) | a.dual() |
| a = b (equality) | | | a = b (identity type) |
About symbols
Symbols are grouped and assigned primarily by additive/multiplicative distinciton. They are corresponding to whether computation exits or rather continues; though concatenation β
/Mul
/*
has conjunctive meaning, computation doesn't complete/exit at not satisfying one criterion for there are still different ways of partition to try (backtracking). Though RegexSet β
/Add
/+
has disjunctive meaning, computation doesn't complete/exit at satisfying one criterion to return which regex has match. On the other hand, alternation β
/Or
/|
and intersection &
/And
/&
early-break, hence order-dependent. When I add Map
variant to Repr
to execute arbitrary functions, this order-dependency suddenly becomes to matter for those arbitrary functions can have effects, for example, modification/replacement of input string. (Effects are additive.)
| | additive | multiplicative | exponential | | - | - | - | - | | positive/extensional | $β$ $0$ Or | $β$ $1$ Mul | ! | | negative/intensional | & β€ And | β β₯ Add | ? |
Laws/Coherence
TODO:
| regular expressions | linear logic/quantale | repr | title | | - | - | - | - | | $a | (b | c) = (a | b) | c$ | $a β (b β c) = (a β b) β c$ | Or(a, Or(b, c)) = Or(Or(a, b), c) | Or-associativity | | | | | | a | a = a | $a β a = a$ | Or(a, a) = a | Or-idempotence | | | $a β 0 = 0 β a = a$ | Or(a, Zero) = Or(Zero, a) = a | Zero, Or-unit | | $a Β· Ξ΅ = Ξ΅ Β· a = a$ | $a β 1 = 1 β a = a$ | Mul(a, One('')) = Mul(One(''), a) = a | One(''), Mul-unit | | $a Β· (b | c)$ | $a β (b β c) = (a β b) β (a β c)$ | Mul(a, Or(b, c)) = Or(Mul(a, b), Mul(a, c)) | right-distributivity | | | $(a β b) β c = (a β c) β (b β c)$ | Mul(Or(a, b), c) = Or(Mul(a, c), Mul(b, c)) | left-distributivity | | $Ξ΅^β = Ξ΅$ | | | | | | (a & b)β = (bβ ) & (aβ )| Rev(Mul(a, b)) = Mul(Rev(b), Rev(a)) | | | | | Mul(One(a), One(b)) = One(ab) | | | | a β (b & c) = (a β b) & (a β c) | Add(a, And(b, c)) = And(Add(a, b), Add(a, c)) | right-distributivity | | | (a & b) β c = (a β c) & (b β c) | Add(And(a, b), c) = And(Add(a, c), Add(b, c)) | left-distributivity | | | a & a = a | And(a, a) = a | And-idempotence |
Relationship among additive, multiplicative and exponential
Linearity (which)
π, derivation
| math | repr | | - | - | | $π(a β b) β π(a) β b + a β π(b)$ | der(Mul(a, b)) = Or(Mul(der(a), b), Mul(a, d(b))) |
True
Stream processor
Flags (TODO)
- i
, CaseInsensitive
- m
, MultiLine
- s
, DotMatchesNewLine
- U
, SwapGreed
- u
, Unicode
- x
, IgnoreWhitespace
Interpretations
Let's not say 'communication'
Algorithms (TODO)
Semantics (TODO)
References