isabelle

How to use complex patterns in functions?

拜拜、爱过 提交于 2019-12-10 21:49:00
问题 Here is a sample function: fun divide :: "enat option ⇒ enat option ⇒ real option" where "divide (Some ∞) _ = None" | "divide _ (Some ∞) = None" | "divide _ (Some 0) = None" | "divide (Some a) (Some b) = Some (a / b)" | "divide _ _ = None" Isabelle HOL shows me the following error: Malformed definition: Non-constructor pattern not allowed in sequential mode. ⋀uw_. divide uw_ (Some 0) = None Why pattern-matching works fine for Some ∞ and doesn't work for Some 0 ? ∞ is a constant for class

Existing constants (e.g. constructors) in type class instantiations

不问归期 提交于 2019-12-10 18:28:56
问题 Consider this Isabelle code theory Scratch imports Main begin datatype Expr = Const nat | Plus Expr Expr it is quite reasonable to instantiate the plus type class to get nice syntax for the Plus constructor: instantiation Expr :: plus begin definition "plus_Exp = Plus" instance.. end But now, + and Plus are still separate constants. In particular, I cannot (easily) use + in a function definition, e.g. fun swap where "swap (Const n) = Const n" | "swap (e1 + e2) = e2 + e1" will print Malformed

What Kind of Type Definitions are Legal in Local Contexts?

谁说胖子不能爱 提交于 2019-12-10 17:22:48
问题 In Isabelle's NEWS file, I found Command 'typedef' now works within a local theory context -- without introducing dependencies on parameters or assumptions, which is not possible in Isabelle/Pure/HOL. Note that the logical environment may contain multiple interpretations of local typedefs (with different non-emptiness proofs), even in a global theory context. (which dates back to Isabelle2009-2). Is this the latest news with respect to typedef and local theory contexts? Further, what does the

Isabelle: Unsupported recursive occurrence of a datatype via type constructor “Set.set”

两盒软妹~` 提交于 2019-12-10 16:23:36
问题 The problem I am wondering if is there a natural way of encoding in Isabelle a grammar like this: type_synonym Var = string datatype Value = VInt int | ... datatype Cmd = Skip | NonDeterministicChoice "Cmd set" | ... The motivation would be to give definition a few specification commands in terms of Non deterministic choice, e.g.: Magic == NonDeterministicChoice {} Rely c r z = Defined using set compreehension and NonDeterministicChoice Isabelle complains about the recursive occurrence of

Isabelle: degree of polynomial multiplied with constant

一笑奈何 提交于 2019-12-10 12:13:02
问题 I am working with the library HOL/Library/Polynomial.thy . A simple property didn't work. E.g., the degree of 2x *2 is equal to the degree of 2x - How can I prove the lemmas (i.e., remove "sorry"): lemma mylemma: fixes y :: "('a::comm_ring_1 poly)" and x :: "('a::comm_ring_1)" shows "1 = 1" (* dummy *) proof- have "⋀ x. degree [: x :] = 0" by simp from this have "⋀ x y. degree (y * [: x :] ) = degree y" sorry (* different notation: *) from this have "⋀ x y. degree (y * (CONST pCons x 0)) =

Trying to generalize a bit vector that uses typedef, bool list, and nat length

僤鯓⒐⒋嵵緔 提交于 2019-12-10 11:02:30
问题 I investigated Coq a little, with its dependent types. I have only the foggiest idea about it all, but now I have in mind that I want a bit vector as a bool list , in which the length of the vector is part of the type. (This question is the possible predecessor of another question. In the next question, if I ask it, I'll ask whether I can recover what I lose, when I use typedef as below.) (For this question, the question is at the bottom) Here are the requirements for the type I want: It has

Gather all non-undefined values after addition

孤人 提交于 2019-12-09 03:43:00
问题 I have the following addition in Isabelle: function proj_add :: "(real × real) × bit ⇒ (real × real) × bit ⇒ (real × real) × bit" where "proj_add ((x1,y1),l) ((x2,y2),j) = ((add (x1,y1) (x2,y2)), l+j)" if "delta x1 y1 x2 y2 ≠ 0 ∧ (x1,y1) ∈ e_aff ∧ (x2,y2) ∈ e_aff" | "proj_add ((x1,y1),l) ((x2,y2),j) = ((ext_add (x1,y1) (x2,y2)), l+j)" if "delta' x1 y1 x2 y2 ≠ 0 ∧ (x1,y1) ∈ e_aff ∧ (x2,y2) ∈ e_aff" | "proj_add ((x1,y1),l) ((x2,y2),j) = undefined" if "delta x1 y1 x2 y2 = 0 ∧ delta' x1 y1 x2 y2

Isabelle matrix arithmetic: det_linear_row_setsum in library with different notation

拥有回忆 提交于 2019-12-08 21:46:30
I recently started using the Isabelle theorem prover. As I want to prove another lemma, I would like to use a different notation than the one used in the lemma "det_linear_row_setsum", which can be found in the HOL library. More specifically, I would like to use the "χ i j notation" instead of "χ i". I have been trying to formulate an equivalent expression for some time, but couldn't figure it out yet. (* ORIGINAL lemma from library *) (* from HOL/Multivariate_Analysis/Determinants.thy *) lemma det_linear_row_setsum: assumes fS: "finite S" shows "det ((χ i. if i = k then setsum (a i) S else c

Isabelle: Why do I get completely different results when running try versus sledgehammer

两盒软妹~` 提交于 2019-12-08 12:54:30
问题 When I look only (this is not stated in the title) at the Sledgehammer results, the output of try often gives various results from sledgehammer while running sledgehammer directly gives zero(!) results. Now I know, the design goal of Sledgehammer was not determinism, as stated by Lawrence Paulson. However, this seemingly random results without understanding why are a bit discouraging for beginners, not only for me but also for students helping in projects. A possibility would be to always run

Isabelle: difference between A * 1 and A ** mat 1

主宰稳场 提交于 2019-12-08 12:49:30
What is the difference between * and ** for matrices and also A * 1 and A ** mat 1`? Example: lemma myexample: fixes A :: "('a::comm_ring_1)^'n∷finite^'n∷finite" shows "(A * 1 = A) ∧ (A ** (mat 1) = A)" by (metis comm_semiring_1_class.normalizing_semiring_rules(12) matrix_mul_rid) Matrices in Isabelle are defined simply as vectors of vectors, so the * on matrices is inherited from vectors, and * on vectors is just componentwise multiplication. Therefore, you have (A*B) $ i $ j = A $ i $ j * B $ i $ j , i.e. * is entry-by-entry multiplication of a matrix. Whether this is actually useful