File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import Validator.Hedge.Grammar
22import Validator.Hedge.IfExpr
33import Validator.Hedge.Language
4+ import Validator.Hedge.Room
45import Validator.Hedge.Types
Original file line number Diff line number Diff line change @@ -309,49 +309,42 @@ def Rule.denote_onlyif {α: Type}
309309theorem Rule.null_commutes {α: Type }
310310 (G: Grammar n φ) (Φ: φ -> α -> Bool) (x: Rule n φ):
311311 ((Rule.null x) = true ) = Regex.Language.null (denote G Φ x) := by
312+ unfold Rule.null
312313 induction x with
313314 | emptyset =>
314315 rw [denote_emptyset]
315316 rw [Regex.Language.null_emptyset]
316- unfold Rule.null
317317 unfold Regex.null
318318 apply Bool.false_eq_true
319319 | emptystr =>
320320 rw [denote_emptystr]
321321 rw [Regex.Language.null_emptystr]
322- unfold Rule.null
323322 unfold Regex.null
324323 simp only
325324 | symbol s =>
326325 obtain ⟨p, children⟩ := s
327326 rw [denote_symbol]
328327 rw [Hedge.Language.null_tree]
329- unfold Rule.null
330328 unfold Regex.null
331329 apply Bool.false_eq_true
332330 | or p q ihp ihq =>
333331 rw [denote_or]
334332 rw [Regex.Language.null_or]
335- unfold Rule.null
336333 unfold Regex.null
337334 rw [<- ihp]
338335 rw [<- ihq]
339- unfold Rule.null
340336 unfold Regex.null
341337 rw [Bool.or_eq_true]
342338 | concat p q ihp ihq =>
343339 rw [denote_concat]
344340 rw [Regex.Language.null_concat_append]
345- unfold Rule.null
346341 unfold Regex.null
347342 rw [<- ihp]
348343 rw [<- ihq]
349- unfold Rule.null
350344 unfold Regex.null
351345 rw [Bool.and_eq_true]
352346 | star r ih =>
353347 rw [denote_star]
354348 rw [Regex.Language.null_star_append]
355- unfold Rule.null
356349 unfold Regex.null
357350 simp only
Original file line number Diff line number Diff line change 1+ import Validator.Std.Hedge
2+
3+ import Validator.Regex.Room
4+ import Validator.Hedge.Grammar
5+ import Validator.Hedge.IfExpr
6+
7+ namespace Hedge.Room
8+
9+ def derive {α: Type }
10+ (G: Grammar n φ) (Φ: φ -> α -> Bool)
11+ (r: Hedge.Grammar.Rule n φ) (x: Hedge.Node α): Hedge.Grammar.Rule n φ :=
12+ Regex.Room.derive (fun (symbol: Hedge.Grammar.Symbol n φ) =>
13+ match x with
14+ | Hedge.Node.mk label children =>
15+ let ifExpr: Hedge.Grammar.Symbol n φ := symbol
16+ let childr: Hedge.Grammar.Rule n φ := Hedge.Grammar.evalif G Φ ifExpr label
17+ let dchildr: Hedge.Grammar.Rule n φ := List.foldl (derive G Φ) childr children
18+ Hedge.Grammar.Rule.null dchildr
19+ ) r
You can’t perform that action at this time.
0 commit comments