Skip to content

Commit 024ddd6

Browse files
author
Virgil Serbanuta
committed
Design document for combining priority axioms
1 parent c397213 commit 024ddd6

File tree

2 files changed

+90
-1
lines changed

2 files changed

+90
-1
lines changed

docs/2020-06-22-Rewrite-Rule-Priorities.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ and we encode the rule as:
168168
∧ ¬ (∃ X₁ . φ₁(X₁) ∧ P₁(X₁))
169169
...
170170
∧ ¬ (∃ Xn . φn(Xn) ∧ Pn(Xn))
171-
psi(X)
171+
ψ(X)
172172
```
173173
Strictly speaking, we should have the left hand side of the encoding of the
174174
respective rules under `∃ Xᵢ` above, but the two forms should be
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
Combining priority axioms
2+
=========================
3+
4+
Background
5+
----------
6+
7+
If we have this chain of axioms: `α₁(X₁)⇒β₁(X₁)``αₙ(Xₙ)⇒βₙ(Xₙ)` in which
8+
all the LHS are *function-like* and *injection-based*, and all the RHS
9+
except `βₙ(Xₙ)` are *function-like*, then their combined transition is
10+
11+
```
12+
(⌈β₁(X₁)∧α₂(X₂)⌉ ∧ ⌈β₂(X₂)∧α₃(X₃)⌉ ∧ … ∧ ⌈βₙ₋₁(Xₙ₋₁)∧αₙ(Xₙ)⌉ ∧ α₁(X₁)) → ••…•βₙ(Xₙ)
13+
```
14+
15+
Also see the [Combining Rewrite Axioms](2019-09-09-Combining-Rewrite-Axioms.md)
16+
document.
17+
18+
Priorities allow writing case-based `K` code that closer resembles functional
19+
languages, i.e. it allows saying things like "Apply this rule first,
20+
if that doesn't work try this other one, if that also doesn't work try
21+
this, and so on". The `owise` attribute is a special case of this.
22+
23+
For a rule `φ(X) ⇒ ψ(X) requires P(X) [priority p]` we take the all
24+
rules at previous priorities:
25+
```
26+
φ₁(X) ⇒ ψ₁(X) requires P₁(X)
27+
...
28+
φn(X) ⇒ ψn(X) requires Pn(X)
29+
```
30+
and we encode the rule as:
31+
```
32+
φ(X) ∧ P(X)
33+
∧ ¬ (∃ X₁ . φ₁(X₁) ∧ P₁(X₁))
34+
...
35+
∧ ¬ (∃ Xn . φn(Xn) ∧ Pn(Xn))
36+
⇒ ψ(X)
37+
```
38+
39+
Also see the [Rewrite Rule Priorities](2020-06-22-Rewrite-Rule-Priorities.md)
40+
document.
41+
42+
Applying the rules
43+
------------------
44+
45+
We will examine how to compute `⌈β(X₁)∧α(X₂)⌉` where `β(X₁)` is the right
46+
hand side of a random rewrite rule and `α(X₂)` is the left hand sight of
47+
priority rewrite rule.
48+
49+
```
50+
⌈β(X₁)∧α(X₂)⌉
51+
= ⌈ β(X₁)∧ φ(X) ∧ P(X)
52+
∧ ¬ (∃ X₁ . φ₁(X₁) ∧ P₁(X₁))
53+
...
54+
∧ ¬ (∃ Xn . φn(Xn) ∧ Pn(Xn))
55+
56+
// If β(X₁) is functional then β(X₁)∧ φ(X) = β(X₁) ∧ ⌈β(X₁)∧ φ(X)⌉
57+
= ⌈ β(X₁) ∧ ⌈β(X₁)∧ φ(X)⌉ ∧ P(X)
58+
∧ ¬ (∃ X₁ . φ₁(X₁) ∧ P₁(X₁))
59+
...
60+
∧ ¬ (∃ Xn . φn(Xn) ∧ Pn(Xn))
61+
62+
// If P is a predicate then ⌈φ∧P⌉=⌈φ⌉∧P
63+
= ⌈ β(X₁)
64+
∧ ¬ (∃ X₁ . φ₁(X₁) ∧ P₁(X₁))
65+
...
66+
∧ ¬ (∃ Xn . φn(Xn) ∧ Pn(Xn))
67+
68+
∧ ⌈β(X₁)∧ φ(X)⌉ ∧ P(X)
69+
// φ(X) ∧ (¬ ∃ Z. α(Z)) = φ(X) ∧ (¬ ∃ Z. ⌈φ(X) ∧ α(Z)⌉)
70+
// See the Justification section in
71+
// 2018-11-08-Configuration-Splitting-Simplification.md
72+
= ⌈β(X₁)
73+
∧ ¬ (∃ X₁ . ⌈ β(X₁) ∧ φ₁(X₁) ∧ P₁(X₁) ⌉)
74+
...
75+
∧ ¬ (∃ Xn . ⌈ β(X₁) ∧ φn(Xn) ∧ Pn(Xn) ⌉)
76+
77+
// If P is a predicate then ⌈φ∧P⌉=⌈φ⌉∧P
78+
= ⌈β(X₁)
79+
∧ ¬ (∃ X₁ . ⌈ β(X₁) ∧ φ₁(X₁) ⌉ ∧ P₁(X₁))
80+
...
81+
∧ ¬ (∃ Xn . ⌈ β(X₁) ∧ φn(Xn) ⌉ ∧ Pn(Xn))
82+
83+
// If P is a predicate then ∃ X . P is a predicate
84+
// If P is a predicate then ⌈φ∧P⌉=⌈φ⌉∧P
85+
= ⌈β(X₁)⌉
86+
∧ ¬ (∃ X₁ . ⌈ β(X₁) ∧ φ₁(X₁) ⌉ ∧ P₁(X₁))
87+
...
88+
∧ ¬ (∃ Xn . ⌈ β(X₁) ∧ φn(Xn) ⌉ ∧ Pn(Xn))
89+
```

0 commit comments

Comments
 (0)