You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+13-8Lines changed: 13 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -127,10 +127,9 @@ def derive_emptystr {α: Type u} {a: α} {w: List α}:
127
127
128
128
For non Lean users: `<;>` is similar to the Monad bind operator (`>>=`) over proof goals. It takes a list of goals to prove and applies the following tactics to each of the goals, which each produce another list of goals, which are all joined together into one list.
129
129
130
-
## Termination Checking
130
+
## Coinduction / Termination Checking
131
131
132
-
[Automatic.lean](./Sodal/Automatic.lean) has a lot of termination checking issues.
133
-
We can safely define Automatic.Lang:
132
+
Lean does not have coinduction, which seems to be required for defining `Automatic.Lang`. We attempt an inductive defintion:
134
133
135
134
```lean
136
135
inductive Lang {α: Type u} : Language.Lang α -> Type (u+1) where
@@ -140,7 +139,10 @@ inductive Lang {α: Type u} : Language.Lang α -> Type (u+1) where
140
139
: Lang R
141
140
```
142
141
143
-
But when we try to instantiate it using any operator, we get termination checking issues, for example given `emptyset`:
142
+
143
+
But this results in a lot of termination checking issues, when instantiating operators in [Automatic.lean](./Sodal/Automatic.lean).
144
+
145
+
For example, when we instantiate `emptyset`:
144
146
```
145
147
-- ∅ : Lang ◇.∅
146
148
def emptyset {α: Type u}: Lang (@Language.emptyset.{u} α) := Lang.mk
@@ -163,7 +165,8 @@ no parameters suitable for structural recursion
163
165
well-founded recursion cannot be used, 'Automatic.emptyset' does not take any (non-fixed) arguments
164
166
```
165
167
166
-
Getting around this issue requires the use of `unsafe`:
168
+
This seems to be a fundamental issue in regards to how inductive types work.
169
+
We can get around this issue by using `unsafe`:
167
170
168
171
```
169
172
-- ∅ : Lang ◇.∅
@@ -175,7 +178,7 @@ def emptyset {α: Type u}: Lang (@Language.emptyset.{u} α) := Lang.mk
175
178
(derive := fun _ => emptyset)
176
179
```
177
180
178
-
This was probably inevitable, given that the Agda version of Lang in [Automatic.lagda](https://github.com/conal/paper-2021-language-derivatives/blob/main/Automatic.lagda#L40-L44) required coinduction, which is not a feature of Lean:
181
+
This issue was probably inevitable, given that the Agda version of Lang in [Automatic.lagda](https://github.com/conal/paper-2021-language-derivatives/blob/main/Automatic.lagda#L40-L44) required coinduction, which is not a feature of Lean:
179
182
180
183
```agda
181
184
record Lang (P : ◇.Lang) : Set (suc ℓ) where
@@ -185,7 +188,7 @@ record Lang (P : ◇.Lang) : Set (suc ℓ) where
185
188
δ : (a : A) → Lang (◇.δ P a)
186
189
```
187
190
188
-
Also this representation encountered issues with Agda's termination checker, but only when defining the derivative of the concat operator, not all operators as in Lean, which was fixed using a sized version of the record:
191
+
Note, the Agda representation also encountered issues with Agda's termination checker, but only when defining the derivative of the concat operator, not all operators as in Lean. Also this was fixable in Agda using a sized version of the record:
189
192
190
193
```agda
191
194
record Lang i (P : ◇.Lang) : Set (suc ℓ) where
@@ -195,7 +198,9 @@ record Lang i (P : ◇.Lang) : Set (suc ℓ) where
195
198
δ : ∀ {j : Size< i} → (a : A) → Lang j (◇.δ P a)
196
199
```
197
200
198
-
We hope to find help to remove the use of `unsafe` in Lean.
201
+
We hope to find help to remove the use of `unsafe` in Lean or that it is possible to fix using a future `coinductive` feature.
202
+
203
+
Apparently there are libraries in Lean that support coinduction, but none that support indexed coinductive types, which is what we require in this case.
0 commit comments