Created
October 13, 2019 03:23
-
-
Save hatsugai/099b23a045902c983d156530a87ce9e1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
theory Stream3 imports Main begin | |
codatatype 'a stream = SCons (shd:'a) (stl:"'a stream") | |
primcorec | |
sadd :: "nat stream => nat stream => nat stream" | |
where | |
"sadd s t = SCons (shd s + shd t) (sadd (stl s) (stl t))" | |
primcorec zeros :: "nat stream" where | |
"zeros = SCons 0 zeros" | |
primcorec ones :: "nat stream" where | |
"ones = SCons 1 ones" | |
lemma "sadd zeros ones = ones" | |
apply(coinduction) | |
apply(auto) | |
done | |
primcorec nf :: "nat => nat stream" where | |
"nf k = SCons k (nf (k + 1))" | |
fun snth :: "nat => nat stream => nat" where | |
"snth 0 s = shd s" | | |
"snth (Suc k) s = snth k (stl s)" | |
lemma "snth k (nf j) = k + j" | |
apply(induction k arbitrary: j) | |
apply(auto) | |
done | |
lemma "sadd (nf k) ones = nf (Suc k)" | |
apply(coinduction arbitrary: k) | |
apply(auto) | |
done | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment