quantifiers

Quantifier range not working in lookbehind

牧云@^-^@ 提交于 2020-01-02 05:05:29
问题 Okay so I'm working on a project where I need a regex that can match a * followed by 1-4 spaces or tabs and then followed by a row of text. Right now I'm using .* after the lookbehind for testing purposes. However I can get it to match explicitly 1, 2, or 4 spaces/tabs but not 1-4. I'm testing against the following block * test line here * Second test * Third test * Another test And these are the two patterns I'm testing (?<=(\*[ \t]{3})).* which works just as expected and matches the 2nd

Understanding Quantifiers

允我心安 提交于 2020-01-01 04:31:05
问题 I was going through the Java Tutorial on Quantifiers. There is a difference mentioned among Differences Among Greedy, Reluctant, and Possessive Quantifiers. I am not able to understand what's the difference exactly. Explanation provided as follows: Enter your regex: .*foo // greedy quantifier Enter input string to search: xfooxxxxxxfoo I found the text "xfooxxxxxxfoo" starting at index 0 and ending at index 13. Enter your regex: .*?foo // reluctant quantifier Enter input string to search:

How can I prove the lemma in Exercise 4.6 in “Programming and Proving in Isabelle/HOL”?

扶醉桌前 提交于 2019-12-24 17:22:07
问题 I am trying to solve Exercise 4.6 in “Programming and Proving in Isabelle/HOL”. It asks to define a function elems :: "'a list ⇒ 'a set" that converts a list into a set, and to prove the lemma "x ∈ elems xs ⟹ ∃ ys zs . xs = ys @ x # zs ∧ x ∉ elems ys" . Until now, I have come that far: fun elems :: "'a list ⇒ 'a set" where "elems [] = {}" | "elems (x # xs) = {x} ∪ elems xs" lemma first_occ: "x ∈ elems xs ⟹ ∃ ys zs . xs = ys @ x # zs ∧ x ∉ elems ys" proof (induction xs) case Nil thus ?case by

Surprising behaviour when trying to prove a forall

北慕城南 提交于 2019-12-20 02:45:10
问题 Consider the following SMT-LIB code: (set-option :auto_config false) (set-option :smt.mbqi false) ; (set-option :smt.case_split 3) (set-option :smt.qi.profile true) (declare-const x Int) (declare-fun trigF (Int Int Int) Bool) (declare-fun trigF$ (Int Int Int) Bool) (declare-fun trigG (Int) Bool) (declare-fun trigG$ (Int) Bool) ; Essentially noise (declare-const y Int) (assert (! (not (= x y)) :named foo )) ; Essentially noise (assert (forall ((x Int) (y Int) (z Int)) (! (= (trigF$ x y z)

Emulating possessive quantifiers

我怕爱的太早我们不能终老 提交于 2019-12-18 04:35:09
问题 Is it possible to emulate possessive quantifiers (.NET doesn’t support it) using atomic grouping (or in other way)? Note. I found that (x+x+)++y can be replaced with (?>(x+x+)+)y , but this is just an example and I don’t know whether always {something}@+ equals to (?>{something}@) (where @ is a quantifier). 回答1: Yup. May I quote the master himself, Jeffrey Friedl, from page 142 of his classic Mastering Regular Expressions (3rd Edition): "In one sense, possessive quantifiers are just syntactic

Greedy Quantifiers

六眼飞鱼酱① 提交于 2019-12-13 04:29:35
问题 I was reading K.Sierra and found the following sentance: The greedy quantifier does in fact read the entire source data, and then it works backward (from the right) until it finds the rightmost match. At that point, it includes everything from earlier in the source data up to and including the data that is part of the rightmost match. Now, Suppose we have a source as follows: "proj3.txt,proj1sched.pdf,proj1,proj2,proj1.java" and pattern: proj1([^,])* why doesn't it match the whole text? Being

formal axiomatic def of an example Kripke model in terms of ∀, ∃

倾然丶 夕夏残阳落幕 提交于 2019-12-13 01:35:21
问题 I am looking for a formal axiomatic definition of an example Kripke model in terms of ∀, ∃ assuming knowledge of simple predicate logic, boolean logic,... All descriptions of Kripke models I encounter simply introduce new notations through paraphrasing to english linguistic concepts (i.e. ☐ = "necessity"). While certainly both helpfull and motivating, it does not assure that I will have the same interpretation of what a Kripke model is as someone else. (this question is the result from good

Z3: Check if model is unique

旧巷老猫 提交于 2019-12-12 14:05:05
问题 Is there a way in Z3 to prove/show that a given model is unique and that no other solution exists? A small example to demonstrate (declare-const a1 Int) (declare-const a2 Int) (declare-const a3 Int) (declare-const b1 Int) (declare-const b2 Int) (declare-const b3 Int) (declare-const c1 Int) (declare-const c2 Int) (declare-const c3 Int) (declare-const ra Int) (declare-const rb Int) (declare-const rc Int) (declare-const r1 Int) (declare-const r2 Int) (declare-const r3 Int) (assert (>= a1 0))

Alternative to possessive quantifier in python

ε祈祈猫儿з 提交于 2019-12-12 07:59:27
问题 I am trying to match all occurences of the String Article followed by a number (single or more digits) which are not followed by an opening parentheses. In Sublime Text, I am using the following regex: Article\s[0-9]++(?!\() to search the following String: Article 29 Article 30(1) which does not match Article 30(1) (as I expect it to) but Article 29 and Article 1 . When attempting to do the same in Python (3) using import re article_list = re.findall(r'Article\s[0-9]++(?!\()', "Article 30(1)"

How do I quantify a group in Javascript's regex? [duplicate]

痞子三分冷 提交于 2019-12-12 05:58:11
问题 This question already has answers here : JavaScript regular expressions and sub-matches (2 answers) Closed 5 years ago . Let's say I had a string "QQxaxbxcQQ", and I wanted to capture all groups of x followed by any character. I also only want to search between the QQ's (the string may include other things in it). I assumed this would have worked: var matches = str.match(/QQ(x\w)+QQ/) However, this only seems to return to me the last match (xc). Can you point me in the right direction? EDIT: