quantifiers

How to use user input as an Quantifier in Regex in JS?

牧云@^-^@ 提交于 2019-12-12 03:19:06
问题 My attempt was : var re = new RegExp("\w{" + n + "}", "g"); But it didn't seems to work. P.S. - I have searched several questions of Stackoverflow thinking it must have been asked before But I didn't find one, so I asked my question. 回答1: The problem is that \ is not only the escape character in regex but also in JS strings. So when you create a regular expression from a string you need to escape it. This means that \w becomes "\\w" in a string and if you want to match a single \ it would

Regex: possessive quantifier for the star repetition operator, i.e. \d**

别说谁变了你拦得住时间么 提交于 2019-12-11 11:53:32
问题 From the GLib Reference Manual, section "Regular expression syntax", subsection "Atomic grouping and possessive quantifiers": Consider the pattern \d+foo when applied to the string 123456bar : after matching all 6 digits and then failing to match "foo", the normal action of the matcher is to try again with only 5 digits matching the \d+ item, and then with 4, and so on, before ultimately failing. If we use (?>\d+)foo (called atomic grouping ) for the previous example, the matcher give up

How can I efficiently prove existential propositions with multiple variables in Isabelle/Isar?

自闭症网瘾萝莉.ら 提交于 2019-12-11 07:30:17
问题 Say I want to prove the lemma ∃ n m k . [n, m, k] = [2, 3, 5] in Isabelle/Isar. If I go ahead as suggested in the Isabelle/HOL tutorial on page 45, my proof looks as follows: lemma "∃ n m k . [n, m, k] = [2, 3, 5]" proof show "∃ m k . [2, m, k] = [2, 3, 5]" proof show "∃ k . [2, 3, k] = [2, 3, 5]" proof show "[2, 3, 5] = [2, 3, 5]" by simp qed qed qed Of course, this is way too verbose. How can I prove propositions like the above one such that the proofs are concise and readable? 回答1:

Just a universally quantified hypotesis in coq proof

本小妞迷上赌 提交于 2019-12-11 06:47:12
问题 Another hard goal (for me, of course) is the following: Goal ~(forall P Q: nat -> Prop, (exists x, P x) /\ (exists x, Q x) -> (exists x, P x /\ Q x)). Proof. I absolutely have no idea of what could I do. If I introduce something, I get a universal quantifier in the hypotesis, and then I can't do anything with it. I suppose that it exists a standard way for managing such kind of situations, but I was not able to find it out. 回答1: To progress in that proof, you will have to exhibit an instance

How exactly does the possessive quantifier work?

江枫思渺然 提交于 2019-12-11 03:22:56
问题 At the end of the page there is at attempted explanation of how do greedy, reluctant and possessive quantifiers work: http://docs.oracle.com/javase/tutorial/essential/regex/quant.html However I tried myself an example and I don't seem to understand it fully. I will paste my results directly: Enter your regex: .*+foo Enter input string to search: xfooxxxxxxfoo No match found. Enter your regex: (.*)+foo Enter input string to search: xfooxxxxxxfoo I found the text "xfooxxxxxxfoo" starting at

Quantifier range not working in lookbehind

杀马特。学长 韩版系。学妹 提交于 2019-12-05 10:45: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 line, same if I replace 3 with 1, 2 or 4 however if I replace it with 1,4 forming the following pattern (?

Quantifier Elimination for LIA in Z3 via C/C++ API

帅比萌擦擦* 提交于 2019-12-05 06:15:29
问题 I would like to use Z3 for eliminating quantifiers in linear integer arithmetic formulas via C/C++ API. Consider a simple example: Exists (x) ( x <= y & y <= 2*x). A quantifier-free formula with the same models is y >= 0. I tried to do it this way: context ctx; ctx.set("ELIM_QUANTIFIERS", "true"); expr x = ctx.int_const("x"); expr y = ctx.int_const("y"); expr sub_expr = (x <= y) && (y <= 2*x); Z3_ast qf = Z3_mk_exists_const(ctx, 0, 1, (Z3_app[]) {x}, 0, {}, // patterns don't seem to make

Quantifier Elimination for LIA in Z3 via C/C++ API

谁说我不能喝 提交于 2019-12-03 19:59:26
I would like to use Z3 for eliminating quantifiers in linear integer arithmetic formulas via C/C++ API. Consider a simple example: Exists (x) ( x <= y & y <= 2*x). A quantifier-free formula with the same models is y >= 0. I tried to do it this way: context ctx; ctx.set("ELIM_QUANTIFIERS", "true"); expr x = ctx.int_const("x"); expr y = ctx.int_const("y"); expr sub_expr = (x <= y) && (y <= 2*x); Z3_ast qf = Z3_mk_exists_const(ctx, 0, 1, (Z3_app[]) {x}, 0, {}, // patterns don't seem to make sense here. sub_expr); //No C++ API for quantifiers :( qf = Z3_simplify(ctx, qf); cout << Z3_ast_to_string

Understanding Quantifiers

狂风中的少年 提交于 2019-12-03 10:59:47
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: xfooxxxxxxfoo I found the text "xfoo" starting at index 0 and ending at index 4. I found the text

Scoped type variables require explicit foralls. Why?

房东的猫 提交于 2019-12-03 07:32:51
问题 If you want to use GHC's lexically scoped type variables, you also have to use explicit universal quantification. That is, you have to add forall declarations to your functions' type signatures: {-# LANGUAGE ExplicitForAll, ScopedTypeVariables #-} f :: forall a . [a] -> [a] -- The `forall` is required here ... f (x:xs) = xs ++ [x :: a] -- ... to relate this `a` to the ones above. Does this actually have anything to do with quantification, or did the extension writers just coopt the forall