Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
3.6k views
in Technique[技术] by (71.8m points)

How to express arrays in Isabelle/HOL?

I am trying to express arrays, but don't know exactly how. For example, in the following toy lemma that asserts the sum of a series of numbers equals to certain things:

lemma " ∑ {x |x. x ∈ {0..(n::nat)} } = n*(n+1) div 2"

, how can I express this for an given array A[i] = i, i = 0..n?

I tried to state it unsuccessfully using vectors (vec) from imports Complex_Main "~~/src/HOL/Analysis/Finite_Cartesian_Product"

as follows:

lemma test_array:
  fixes n::nat and A::"(nat,3) vec"
  shows "∑ {A $ x |x. x ∈ {0..(3::nat)} } = 3*4 div 2"

First of all, I don't know how to get vec to accept a parameter n about its size. Secondly, the conclusion part "∑ {A $ x |x. x ∈ {0..(3::nat)} } has some type errors. Maybe vec isn't the right solution. Hence the question here.

In Isabelle, is there any (preferably standard) way to express the array A[i] for i in a range?

(To clarify, I do not need imperative arrays that can be modified as in programming; I just needed mathematical arrays with a size that is known in advance but not fixed to something like 3).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神解答

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

56.6k users

...