Skip to content

Commit a9f7918

Browse files
massive cleanup
Delete Hott Delete RegexNotation Delete TDecidable
1 parent 4150dbf commit a9f7918

16 files changed

+208
-1461
lines changed

Katydid.lean

+7-12
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
1-
-- import Katydid.Std.Lists
2-
-- import Katydid.Std.Ltac
3-
-- import Katydid.Std.Balistic
4-
-- import Katydid.Std.TDecidable
1+
import Katydid.Std.Lists
2+
import Katydid.Std.Ltac
3+
import Katydid.Std.Balistic
54
-- import Katydid.Std.Tipe
65

7-
-- import Katydid.Conal.Language
8-
-- import Katydid.Conal.LanguageNotation
9-
-- import Katydid.Conal.Calculus
10-
-- import Katydid.Conal.RegexNotation
11-
-- import Katydid.Conal.Examples
12-
import Katydid.Conal.LanguageHott
13-
import Katydid.Conal.LanguageNotationHott
14-
import Katydid.Conal.CalculusHott
6+
import Katydid.Conal.Language
7+
import Katydid.Conal.LanguageNotation
8+
import Katydid.Conal.Calculus
9+
import Katydid.Conal.Examples

Katydid/Conal/Calculus.lean

+49-54
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,34 @@
11
-- A translation to Lean from Agda
22
-- https://github.com/conal/paper-2021-language-derivatives/blob/main/Calculus.lagda
33

4-
import Katydid.Std.Tipe
54
import Katydid.Conal.LanguageNotation
6-
import Katydid.Std.TDecidable
5+
import Mathlib.Logic.Equiv.Defs -- ≃
76
open Lang
8-
open TDecidable
7+
open List
8+
open Char
9+
open String
910

1011
-- Print Parse
11-
set_option pp.all true
12+
-- set_option pp.all true
1213
open List
13-
def a_or_b := ({'a'}{'b'})
14+
def a_or_b := (char 'a'char 'b')
1415
#print a_or_b
15-
def a_or_b_parse_a := a_or_b ['a']
16+
def a_or_b_parse_a := a_or_b (toList "a")
1617
-- #eval a_or_b_parse_a
1718

18-
def p : a_or_b ['a'] -> Nat := by
19+
def p : a_or_b (toList "a") -> Nat := by
1920
intro x
2021
cases x with
2122
| inl xa =>
2223
cases xa with
23-
| refl => exact 0
24+
| mk eq =>
25+
cases eq with
26+
| refl =>
27+
exact 0
2428
| inr xb =>
25-
contradiction
29+
cases xb with
30+
| mk eq =>
31+
contradiction
2632

2733
-- ν⇃ : Lang → Set ℓ -- “nullable”
2834
-- ν⇃ P = P []
@@ -42,6 +48,7 @@ theorem nullable_emptySet:
4248
∀ (α: Type),
4349
@ν α ∅ ≡ PEmpty := by
4450
intro α
51+
constructor
4552
rfl
4653

4754
-- ν𝒰 : ν 𝒰 ≡ ⊤
@@ -50,6 +57,7 @@ theorem nullable_universal:
5057
∀ (α: Type),
5158
@ν α 𝒰 ≡ PUnit := by
5259
intro α
60+
constructor
5361
rfl
5462

5563
-- ν𝟏 : ν 𝟏 ↔ ⊤
@@ -60,39 +68,41 @@ theorem nullable_universal:
6068
-- (λ { refl → refl })
6169
theorem nullable_emptyStr:
6270
∀ (α: Type),
63-
@ν α ε PUnit := by
71+
@ν α ε PUnit := by
6472
intro α
65-
refine Tiso.intro ?a ?b ?c ?d
66-
intro
73+
refine Equiv.mk ?a ?b ?c ?d
74+
intro _
6775
exact PUnit.unit
68-
intro
69-
exact trifle
70-
intro
71-
exact trifle
76+
intro _
77+
constructor
78+
rfl
79+
intro c
80+
simp
81+
constructor
82+
intro _
7283
simp
73-
intro x
74-
cases x with
75-
| _ => exact trifle
7684

7785
theorem nullable_emptyStr':
7886
∀ (α: Type),
79-
@ν α ε PUnit :=
80-
fun _ => Tiso.intro
87+
@ν α ε PUnit :=
88+
fun _ => Equiv.mk
8189
(fun _ => PUnit.unit)
82-
(fun _ => trifle)
90+
(fun _ => by constructor; rfl)
8391
(sorry)
8492
(sorry)
8593

8694
-- ν` : ν (` c) ↔ ⊥
8795
-- ν` = mk↔′ (λ ()) (λ ()) (λ ()) (λ ())
8896
theorem nullable_char:
8997
∀ (c: α),
90-
ν (char c) PEmpty := by
98+
ν (char c) PEmpty := by
9199
intro α
92100
simp
93-
apply Tiso.intro
94-
intro
95-
contradiction
101+
apply Equiv.mk
102+
intro x
103+
cases x with
104+
| mk x =>
105+
contradiction
96106
intro
97107
contradiction
98108
sorry
@@ -104,42 +114,20 @@ theorem nullable_char':
104114
intro
105115
refine (fun x => ?c)
106116
simp at x
107-
contradiction
117+
cases x with
118+
| mk x =>
119+
contradiction
108120

109121
-- set_option pp.all true
110122
-- #print nullable_char'
111123

112-
theorem t : 12 -> False := by
113-
intro
114-
contradiction
115-
116-
theorem t'' : 1 = 2 -> False := by
117-
intro
118-
contradiction
119-
120-
theorem t''' : 1 = 2 → False :=
121-
fun a => absurd a (of_decide_eq_false (Eq.refl (decide (1 = 2))))
122-
123-
theorem t' : 12 → False :=
124-
fun a =>
125-
(TEq.casesOn (motive := fun a_1 x => 2 = a_1 → HEq a x → False) a
126-
(fun h => Nat.noConfusion h fun n_eq => Nat.noConfusion n_eq) (Eq.refl 2) (HEq.refl a)).elim
127-
128-
theorem nullable_char'''.{u_2, u_1} : {α : Type u_1} → (c : α) → ν.{u_1} (Lang.char.{u_1} c) → PEmpty.{u_2} :=
129-
fun {α : Type u_1} (c : α) (x : ν.{u_1} (Lang.char.{u_1} c)) =>
130-
False.elim.{u_2}
131-
(False.elim.{0}
132-
(TEq.casesOn.{0, u_1} (motive := fun (a : List.{u_1} α) (x_1 : TEq.{u_1} List.nil.{u_1} a) =>
133-
Eq.{u_1 + 1} (List.cons.{u_1} c List.nil.{u_1}) a → HEq.{u_1 + 1} x x_1 → False) x
134-
(fun (h : Eq.{u_1 + 1} (List.cons.{u_1} c List.nil.{u_1}) List.nil.{u_1}) => List.noConfusion.{0, u_1} h)
135-
(Eq.refl.{u_1 + 1} (List.cons.{u_1} c List.nil.{u_1})) (HEq.refl.{u_1 + 1} x)))
136-
137124
-- ν∪ : ν (P ∪ Q) ≡ (ν P ⊎ ν Q)
138125
-- ν∪ = refl
139126
theorem nullable_or:
140127
∀ (P Q: Lang α),
141128
ν (P ⋃ Q) ≡ (Sum (ν P) (ν Q)) := by
142129
intro P Q
130+
constructor
143131
rfl
144132

145133
-- ν∩ : ν (P ∩ Q) ≡ (ν P × ν Q)
@@ -148,6 +136,7 @@ theorem nullable_and:
148136
∀ (P Q: Lang α),
149137
ν (P ⋂ Q) ≡ (Prod (ν P) (ν Q)) := by
150138
intro P Q
139+
constructor
151140
rfl
152141

153142
-- ν· : ν (s · P) ≡ (s × ν P)
@@ -156,6 +145,7 @@ theorem nullable_scalar:
156145
∀ (s: Type) (P: Lang α),
157146
ν (Lang.scalar s P) ≡ (Prod s (ν P)) := by
158147
intro P Q
148+
constructor
159149
rfl
160150

161151
-- ν⋆ : ν (P ⋆ Q) ↔ (ν P × ν Q)
@@ -166,7 +156,7 @@ theorem nullable_scalar:
166156
-- (λ { (([] , []) , refl , νP , νQ) → refl})
167157
theorem nullable_concat:
168158
∀ (P Q: Lang α),
169-
ν (P, Q) (Prod (ν Q) (ν P)) := by
159+
ν (P, Q) (Prod (ν Q) (ν P)) := by
170160
-- TODO
171161
sorry
172162

@@ -200,7 +190,7 @@ theorem nullable_concat:
200190
-- ∎ where open ↔R
201191
theorem nullable_star:
202192
∀ (P: Lang α),
203-
ν (P *) List (ν P) := by
193+
ν (P *) List (ν P) := by
204194
-- TODO
205195
sorry
206196

@@ -210,6 +200,7 @@ theorem derivative_emptySet:
210200
∀ (a: α),
211201
(δ ∅ a) ≡ ∅ := by
212202
intro a
203+
constructor
213204
rfl
214205

215206
-- δ𝒰 : δ 𝒰 a ≡ 𝒰
@@ -218,6 +209,7 @@ theorem derivative_universal:
218209
∀ (a: α),
219210
(δ 𝒰 a) ≡ 𝒰 := by
220211
intro a
212+
constructor
221213
rfl
222214

223215
-- δ𝟏 : δ 𝟏 a ⟷ ∅
@@ -252,6 +244,7 @@ theorem derivative_or:
252244
∀ (a: α) (P Q: Lang α),
253245
(δ (P ⋃ Q) a) ≡ ((δ P a) ⋃ (δ Q a)) := by
254246
intro a P Q
247+
constructor
255248
rfl
256249

257250
-- δ∩ : δ (P ∩ Q) a ≡ δ P a ∩ δ Q a
@@ -260,6 +253,7 @@ theorem derivative_and:
260253
∀ (a: α) (P Q: Lang α),
261254
(δ (P ⋂ Q) a) ≡ ((δ P a) ⋂ (δ Q a)) := by
262255
intro a P Q
256+
constructor
263257
rfl
264258

265259
-- δ· : δ (s · P) a ≡ s · δ P a
@@ -268,6 +262,7 @@ theorem derivative_scalar:
268262
∀ (a: α) (s: Type) (P: Lang α),
269263
(δ (Lang.scalar s P) a) ≡ (Lang.scalar s (δ P a)) := by
270264
intro a s P
265+
constructor
271266
rfl
272267

273268
-- δ⋆ : δ (P ⋆ Q) a ⟷ ν P · δ Q a ∪ δ P a ⋆ Q

0 commit comments

Comments
 (0)