| 1 |
; *********************************************************** |
| 2 |
; ; Adapt path if necessary: |
| 3 |
; (define path "~/minlog/examples/tait/diplomarbeit_schlenker/") |
| 4 |
|
| 5 |
; ; Defines the function "pload" to load files |
| 6 |
; ; from the path defined above |
| 7 |
; (define pload (lambda (x) (load (string-append path x)))) |
| 8 |
|
| 9 |
; ; Used Modules: |
| 10 |
; (pload "./initiate.scm") |
| 11 |
; (pload "./defsLamCalc.scm") |
| 12 |
; |
| 13 |
; NOTICE: Uncomment modules only when file is run on its own |
| 14 |
; *********************************************************** |
| 15 |
|
| 16 |
|
| 17 |
; ======================================= |
| 18 |
; Section: Definitions for Substitution |
| 19 |
; ======================================= |
| 20 |
|
| 21 |
; Definition: "Sublist" |
| 22 |
; --------------------- |
| 23 |
; "Sublist" stands for "Substitution list" |
| 24 |
|
| 25 |
(add-alg "Sublist" |
| 26 |
'("Up" "nat=>Sublist") |
| 27 |
'("Dot" "term=>Sublist=>Sublist")) |
| 28 |
|
| 29 |
(add-var-name "theta" (py "Sublist")) |
| 30 |
|
| 31 |
; Definition: "Lift" |
| 32 |
; ------------------ |
| 33 |
; lifts terms with respect to given l and k |
| 34 |
|
| 35 |
(add-program-constant "Lift" (py "term=>nat=>nat=>term") 1) |
| 36 |
|
| 37 |
(add-computation-rule (pt "Lift (Var n) l k") |
| 38 |
(pt "[if (n<l) (Var n) (Var(n+k))]")) |
| 39 |
(add-computation-rule (pt "Lift (App r s) l k") |
| 40 |
(pt "App (Lift r l k)(Lift s l k)")) |
| 41 |
(add-computation-rule (pt "Lift(Abs rho r)l k") |
| 42 |
(pt "Abs rho (Lift r(l+1)k)")) |
| 43 |
|
| 44 |
; Definition: "Sublift" |
| 45 |
; --------------------- |
| 46 |
; lifts substitution lists |
| 47 |
|
| 48 |
(add-program-constant "Sublift" |
| 49 |
(py "Sublist=>nat=>Sublist") 1 'const 2) |
| 50 |
|
| 51 |
(add-computation-rule (pt "Sublift(Up m)n") (pt "Up(m+n)")) |
| 52 |
(add-computation-rule (pt "Sublift(Dot r theta)n") |
| 53 |
(pt "Dot(Lift r 0 n)(Sublift theta n)")) |
| 54 |
|
| 55 |
; Definition: "Sub" |
| 56 |
; ----------------- |
| 57 |
; substitution of a term r by a substitution list theta |
| 58 |
|
| 59 |
(add-program-constant "Sub" (py "term=>Sublist=>term") 1 'const 2) |
| 60 |
|
| 61 |
(add-computation-rule (pt "Sub(Var 0)(Dot r theta)") (pt "r")) |
| 62 |
(add-computation-rule (pt "Sub(Var(Succ n))(Dot r theta)") |
| 63 |
(pt "Sub(Var n)theta")) |
| 64 |
(add-computation-rule (pt "Sub(Var n)(Up m)") (pt "Var(n+m)")) |
| 65 |
(add-computation-rule (pt "Sub(r s)theta") |
| 66 |
(pt "(Sub r theta)(Sub s theta)")) |
| 67 |
(add-computation-rule (pt "Sub(Abs rho r)theta") |
| 68 |
(pt "(Abs rho (Sub r(Dot(Var 0) |
| 69 |
(Sublift theta 1))))")) |
| 70 |
|
| 71 |
; Definition: Seq |
| 72 |
; --------------- |
| 73 |
; creates a list on natural numbers from n to (n+l) |
| 74 |
|
| 75 |
(add-program-constant "Seq" (py "nat=>nat=>list nat") 1) |
| 76 |
|
| 77 |
(add-computation-rule (pt "Seq n 0") (pt "(Nil nat)")) |
| 78 |
(add-computation-rule (pt "Seq n(Succ l)") (pt "n::Seq(Succ n)l")) |
| 79 |
|
| 80 |
; (pp (nt (pt "Seq 2 5"))) |
| 81 |
; => 2::3::4::5::6: |
| 82 |
|
| 83 |
; Definition: Wrap |
| 84 |
; ---------------- |
| 85 |
; wraps up a list of terms to a Sublist with a parameter for lifting |
| 86 |
|
| 87 |
(add-program-constant "Wrap" (py "nat=>list term=>Sublist") 1) |
| 88 |
|
| 89 |
(add-var-name "termlist" (py "list term")) |
| 90 |
|
| 91 |
(add-computation-rule (pt "Wrap n (Nil term)")(pt "Up n")) |
| 92 |
(add-computation-rule (pt "Wrap n (r::termlist)") |
| 93 |
(pt "Dot r (Wrap n termlist)")) |