-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathnotes.txt
More file actions
195 lines (83 loc) · 1.76 KB
/
Copy pathnotes.txt
File metadata and controls
195 lines (83 loc) · 1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
Lambda Calculus
; formal syntax
M, N ::= x | λx. M | M N
; free variable (not bound)
FV(x) = {x}
FV(λx. M) = FV(M) \ {x}
FV(M N) = FV(M) ∪ FV(N)
; β reduction
(λx. M) N -> M[x := N]
; examples
λx. 1 2 -> 1
λx. x 1 -> 1
λx.λx.x 1 -> λx.x
λx.λy. x 1 -> λy.1
; curry transformation or curring
λx.λy. x*y 2 3
λy. 2*y 3
2*3
; α transformation
λx. M ≡ λy. M[x := y]
; η transformation
λx. f x ≡ f
; normal form (terminal form)
(λx. x x) (λx. x x) -> Ω ; infinte loop
true ≡ λt.λf. t
function true(t, f) { returns t}
false ≡ λt.λf. f
function false(t, f) { returns f}
if ≡ λb.λt.λe. b t e ; e - else
;JS b ? t : e
; Church numerals
0 ≡ λf.λx. x
1 ≡ λf.λx. f x
2 ≡ λf.λx. f (f x)
..
..
succ ≡ λn.λf.λx. f (n f x)
; fixed point combinator
; Y combinator
Y ≡ λf. (λ.x f (x x)) (λx. f (x x))
Y f -> f (Y f)
Any set
S
S1 + S2 ; elements from S1 and S2
S1 * S2 ; {(S1, S2), ...}
S1 = {1 2 3}
S2 = {4 5 6}
S1 * S2 = {(1 4) (1 5) (1 6) (2 4) (2 5) (2 6) (3 4) (3 5) (3 6)}
S1 * S1 = {(1 2) (1 3) (2 1) (2 3) (3 1) (3 2) (1 1) (2 2) (3 3)}
; relation
== {(1 1) (2 2) (3 3)}
> {(2 1) (3 1) (3 2)}
; JAVA
a = new MyClass(1);
b = new MyClass(2);
c = new MyClass(2);
required that equals() is properly implemented on MyClass
; identity eq
a == b -> false
b == c -> false
a == a -> true
; value eq
a.equals(b) -> false
b.equals(c) -> true
a.equals(a) -> true
s1 = "hello"
s2 = "Hello"
s1.equals(s2) -> false
s1.equalsIgnoreCase(s2) -> true
List<A>
List<B>
B <- a
List<B> <- List<A> -?
SQL
select *
from A, A
where A.x > A.y
union +
A -> B -> C -> D -> 0
a ~> A
b = conj a Z
Z -> A -> B -> C -> D -> 0
//b ~> Z