Skip to content

Commit bc1637e

Browse files
committed
WIP
1 parent ce9c7b7 commit bc1637e

File tree

3 files changed

+539
-8
lines changed

3 files changed

+539
-8
lines changed

.gitignore

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# VIM
2+
*.ll
3+
*~
4+
*.swp
5+
*.swo
6+
.*.marks
7+
8+
\#*
9+
output
10+
paper/nu-TL-paper/
11+
Phi_System/Overleaf-CoP-paper
12+

Uniswap.thy

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
theory Uniswap
2-
imports PhiSem_Machine_Integer PhiSem_CF_Basic PhiSem_Variable HOL.Transcendental
2+
imports Phi_Semantics.PhiSem_Machine_Integer
3+
Phi_Semantics.PhiSem_CF_Basic
4+
Phi_Semantics.PhiSem_Variable HOL.Transcendental
35
begin
46

57
consts Tick :: \<open>(VAL, int) \<phi>\<close>
@@ -86,10 +88,10 @@ qed
8688

8789
debt_axiomatization getSqrtRatioAtTick :: \<open>(VAL,VAL) proc'\<close>
8890
where getSqrtRatioAtTick_\<phi>app:
89-
\<open>\<^bold>p\<^bold>r\<^bold>o\<^bold>c getSqrtRatioAtTick v \<lbrace> t \<Ztypecolon> \<^bold>v\<^bold>a\<^bold>l[v] Tick \<longmapsto> price_of t \<Ztypecolon> \<^bold>v\<^bold>a\<^bold>l Price \<rbrace>\<close>
91+
\<open>\<p>\<r>\<o>\<c> getSqrtRatioAtTick v \<lbrace> t \<Ztypecolon> \<v>\<a>\<l>[v] Tick \<longmapsto> price_of t \<Ztypecolon> \<v>\<a>\<l> Price \<rbrace>\<close>
9092
and getTickAtSqrtRatio_\<phi>app:
91-
\<open>\<^bold>p\<^bold>r\<^bold>e\<^bold>m\<^bold>i\<^bold>s\<^bold>e 0 < p
92-
\<Longrightarrow> \<^bold>p\<^bold>r\<^bold>o\<^bold>c getTickAtSqrtRatio v \<lbrace> p \<Ztypecolon> \<^bold>v\<^bold>a\<^bold>l[v] Price \<longmapsto> tick_of_price p \<Ztypecolon> \<^bold>v\<^bold>a\<^bold>l Tick \<rbrace>\<close>
93+
\<open>\<p>\<r>\<e>\<m>\<i>\<s>\<e> 0 < p
94+
\<Longrightarrow> \<p>\<r>\<o>\<c> getTickAtSqrtRatio v \<lbrace> p \<Ztypecolon> \<v>\<a>\<l>[v] Price \<longmapsto> tick_of_price p \<Ztypecolon> \<v>\<a>\<l> Tick \<rbrace>\<close>
9395

9496
record tick_info =
9597
liquidityGross :: nat
@@ -102,16 +104,31 @@ record tick_info =
102104
initialized :: bool
103105

104106
definition \<open>growth_Inv f f' delta current =
105-
(\<forall>i. f i = (if i \<le> current then (sum f' {j. j \<le> i}) + delta i else (sum f' {j. i < j}) - delta i))\<close>
107+
(\<forall>(i::int). f i = (if i \<le> current then (sum f' {j. j \<le> i}) + delta i
108+
else (sum f' {j. i < j}) - delta i))\<close>
106109

107110

108111
term sum
109112

110113

111-
consts TickInfo' :: \<open>(VAL, tick_info) \<phi>\<close>
112-
TickInfos :: \<open>(assn, int \<Rightarrow> tick_info) \<phi>\<close>
114+
debt_axiomatization TickInfos :: \<open>(assn, int \<Rightarrow> tick_info nonsepable option) \<phi>\<close>
115+
where TickInfos_mult: \<open>(f1 \<Ztypecolon> TickInfos) * (f2 \<Ztypecolon> TickInfos) = (f1 * f2 \<Ztypecolon> TickInfos)\<close>
116+
\<comment> \<open>Separation of Abstraction ?! cool! \<close>
113117

114-
definition \<open>TickInfo = (\<lambda>info. into \<Ztypecolon> TickInfo' \<^bold>s\<^bold>u\<^bold>b\<^bold>j )\<close>
118+
thm TickInfos_mult
119+
120+
definition TickInfo
121+
122+
123+
debt_axiomatization get_TickInfo :: \<open>(VAL,VAL) proc'\<close>
124+
where getSqrtRatioAtTick_\<phi>app:
125+
\<open>\<p>\<r>\<o>\<c> getSqrtRatioAtTick v \<lbrace> t \<Ztypecolon> \<v>\<a>\<l>[v] Tick \<longmapsto> price_of t \<Ztypecolon> \<v>\<a>\<l> Price \<rbrace>\<close>
126+
and getTickAtSqrtRatio_\<phi>app:
127+
\<open>\<p>\<r>\<e>\<m>\<i>\<s>\<e> 0 < p
128+
\<Longrightarrow> \<p>\<r>\<o>\<c> getTickAtSqrtRatio v \<lbrace> p \<Ztypecolon> \<v>\<a>\<l>[v] Price \<longmapsto> tick_of_price p \<Ztypecolon> \<v>\<a>\<l> Tick \<rbrace>\<close>
129+
130+
131+
definition \<open>Ticks = (\<lambda>info. into \<Ztypecolon> TickInfo' \<s>\<u>\<b>\<j> )\<close>
115132

116133

117134
end

0 commit comments

Comments
 (0)