我想創建一個新的數據類型形狀像一箇舊的,但(不像使用type_synonym
)它應該被認爲是不同的其他理論。Isabelle等價於Haskell newtype嗎?
我的激勵示例:我從列表中製作堆棧數據類型。我不希望我的其他理論看我stack
S作爲list
這麼我可以強制對我自己的簡化規則,但我已經找到了唯一的解決辦法是:
datatype 'a stk = S "'a list"
...
primrec index_of' :: "'a list => 'a => nat option"
where "index_of' [] b = None"
| "index_of' (a # as) b = (
if b = a then Some 0
else case index_of' as b of Some n => Some (Suc n) | None => None)"
primrec index_of :: "'a stk => 'a => nat option"
where "index_of (S as) x = index_of' as x"
...
lemma [simp]: "index_of' del v = Some m ==> m <= n ==>
index_of' (insert_at' del n v) v = Some m"
<proof>
lemma [simp]: "index_of del v = Some m ==> m <= n ==>
index_of (insert_at del n v) v = Some m"
by (induction del, simp)
它的工作原理,但這意味着我的理論膨脹並且充滿了過多的冗餘:每個函數都有第二個版本剝離構造函數,每個定理都有第二個版本(證明是總是by (induction del, simp)
,這讓我感覺像一個符號我在某處做了太多工作)。
有沒有什麼可以幫到這裏?
謝謝!因此,我用'lift_definition index_of ::''a env =>'a => nat選項「is index_of'by simp' 替換我的'index_of'定義,然後證明只是用一個引理而不是兩個? – Zyzzyva 2014-12-11 15:53:49
因爲這些函數可以工作,但是嘗試證明它不會在'list'上對'stack's進行歸納:它只是增加一個'ya:{xs。 True} ==>'前提。我怎樣才能讓它提升證明呢? – Zyzzyva 2014-12-11 16:02:00