public static Lemma getRandomLemma() { // Get a random lemma from the DB. Lemma lemma = DBConnect.GetRandomLemma(); return(lemma); }
public static void addToFavorites(int userID, string lemmaTitle) { // Get the properties needed for the creation of Lemma object byte[] lemmaBody = DBConnect.GetLemmaBodyByTitle(lemmaTitle); int lemmaCategory = DBConnect.GetLemmaCategoryByTitle(lemmaTitle); Lemma lemma = new Lemma(lemmaTitle, lemmaBody, lemmaCategory); // Get the properties needed for the creation of User object. string userName = DBConnect.GetUserNameByID(userID); string userSurname = DBConnect.GetUserSurnameByID(userID); DateTime dateOfBirth = DBConnect.GetUserDateOfBirthByID(userID); User user = new User(userID, userName, userSurname, dateOfBirth); DateTime createdAt = DateTime.Now; // Create a FavoriteLemma object with the above properties. FavoriteLemma fLemma = new FavoriteLemma(lemma.Title, user, createdAt); // Insert the favorite lemma to DB. int result = DBConnect.Insert(fLemma); if (result == 1) // If result=1 then everything is OK. { FavouriteLemmataUserControl.Instance.FavoriteLemmas.Add(fLemma); FavouriteLemmataUserControl.Instance.SetLemmas(); } else // If result!=1 then something went wrong. { MessageBox.Show(" The Lemma wasn't added to Favorites. Try again!"); } }
public LemmaEditor(Lemma lemma, int mode) { InitializeComponent(); this.Lemma = lemma; this.Mode = mode; lemmaTitleLabel.Text = lemma.Title + " - Edited By '" + StartPage.account.User.Name + "'"; }
// // Methodos pou eisagei to klikarismeno label sto istoriko . // public void addhistory(object lemma, object lemmaname2) { Lemma lmid = lemma as Lemma; Label lbl = lemmaname2 as Label; cm.addLemmaToHistory(lmid.getLemmaIDbyLemmaName(lbl.Text)); }
/*----------------------------------------------------------------------------*/ private void AddLemma(Lemma lemma) { lemma.id = findMinID(); StreamWriter SW = new StreamWriter(Path.GetFullPath(path), true); SW.WriteLine(lemma.ToLine()); SW.Close(); }
private void AddWordToDictionary(Lemma lemma, string word) { if (!_lemmas.ContainsKey(word)) { _lemmas[word] = new List<Lemma>(); } _lemmas[word].Add(lemma); }
public void Information_WordNotFound() { //Parameters out Parameters.QueryWord = "inexistantword"; Lemma result = Collector.GatherData <Lemma>(Parameters).Result; Assert.IsNull(result); }
public void ProcessLemma(Lemma lemma) { AddWordToDictionary(lemma, lemma.Text); foreach (LemmaForm form in lemma.Forms) { AddWordToDictionary(lemma, form.Text); } }
/// <summary> /// Serves as a hash function for a particular type. /// </summary> /// <returns> /// A hash code for the current <see cref="T:System.Object"/>. /// </returns> public override int GetHashCode() { unchecked { var hashCode = (Class != null ? Class.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Lemma != null ? Lemma.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Features != null ? Features.GetHashCode() : 0); return(hashCode); } }
public static Lemma CopyLemma(MemberDecl md) { Lemma oldLm = md as Lemma; if (oldLm == null) { return(null); } return(CopyLemma(oldLm)); }
private void UseLemma2to6(CspInstance instance, Lemma lemma) { foreach (var v in instance.Variables) { lemma(instance, v, out bool applied); if (applied) { UseLemma2to6(instance, lemma); return; } } }
public override string ToString() { StringBuilder result = new StringBuilder(200); result.Append("word: ").Append(WordForm.ToString()).Append(" | "); result.Append("position: ").Append(Position.ToString()).Append(" | "); result.Append("lemma: ").Append(Lemma.ToString()).Append(" | "); result.Append("cpos: ").Append(CPOSTag.ToString()).Append(" | "); result.Append("parent: ").Append(HeadNumber.ToString()).Append(" | "); result.Append("count: ").Append(TokenCount.ToString()).Append(" | ").Append("chasbidegi:").Append(ChasbidegiType.ToString()); return(result.ToString()); }
public EsEntry Step2_MakeEsEntry() { var ws = WordForm.Split(' '); var ls = Lemma.Split(' '); var ps = PosTag.Split(' '); switch (ws.Length) { case 1: return(new EsEntry { Key = Key, N = N, W0 = $"µ{ws[0]}µ", L0 = $"µ{ls[0]}µ", P0 = $"µ{ps[0]}µ", }); case 2: return(new EsEntry { Key = Key, N = N, W0 = $"µ{ws[0]}µ", W1 = $"µ{ws[1]}µ", L0 = $"µ{ls[0]}µ", L1 = $"µ{ls[1]}µ", P0 = $"µ{ps[0]}µ", P1 = $"µ{ps[1]}µ", }); case 3: return(new EsEntry { Key = Key, N = N, W0 = $"µ{ws[0]}µ", W1 = $"µ{ws[1]}µ", W2 = $"µ{ws[2]}µ", L0 = $"µ{ls[0]}µ", L1 = $"µ{ls[1]}µ", L2 = $"µ{ls[2]}µ", P0 = $"µ{ps[0]}µ", P1 = $"µ{ps[1]}µ", P2 = $"µ{ps[2]}µ", }); } return(null); }
public void Delete(TheoryTypes type, int theoryindex, string formulation, string template, string proof) { ITheoryElement element = null; switch (type) { case TheoryTypes.Corollary: element = new Corollary(theoryindex, formulation, template); break; case TheoryTypes.Definition: element = new Definition(theoryindex, formulation, template); break; case TheoryTypes.Lemma: element = new Lemma(theoryindex, formulation, template); break; case TheoryTypes.Postulate: element = new Postulate(theoryindex, formulation, template); break; case TheoryTypes.Theorem: element = new Theorem(theoryindex, formulation, template, proof); break; } tree.Remove(element); }
public void SetLemmaData(string lemmaTitle, int mode) { if (mode == 0) { byte[] body = DBConnect.GetLemmaBodyByTitle(lemmaTitle); int categoryId = DBConnect.GetLemmaCategoryByTitle(lemmaTitle); Lemma = new Lemma(lemmaTitle, body, categoryId); } else { EditedLemma = DBConnect.GetEditedLemmaByUserAndTitle(lemmaTitle, StartPage.account.User); } }
public Coordination(int id, string lemma, string dependency) : base(id, lemma, dependency) { var stringEnumValue = Lemma.ToUpper(); if (Enum.IsDefined(typeof(CoordinationType), stringEnumValue)) { this.CoordinationType = (CoordinationType)Enum.Parse(typeof(CoordinationType), Lemma.ToUpper()); } else { this.CoordinationType = CoordinationType.DEFAULT; } }
// // EVENT: Otan patietai to koumpi bookmark kai exei epilexthei ena lemma, apothikeuei to lemma sto BOOKMARK // private void bookmarkB_Click(object sender, EventArgs e) { Lemma lmid = sender as Lemma; if (lemmatext != null) { lm.add_to_bookmark(lemmaname, lemmaname); } else { MessageBox.Show("Δεν έχετε επιλέξει λήμμα"); } }
public NewLemmaPage() { InitializeComponent(); lemma = new Lemma { theme = "Thème.", lieu = "Lieu", description = "Description", date = DateTime.Now }; BindingContext = this; }
/*----------------------------------------------------------------------------*/ private void EditLemma(Lemma editLemma) { int index = VM.LemmaList.FindIndex(l => l.id == editLemma.id); VM.LemmaList[index] = editLemma; StreamWriter SW = new StreamWriter(path); foreach (Lemma lemma in VM.LemmaList) { SW.WriteLine(lemma.ToLine()); } SW.Close(); }
public string ToTable() { StringBuilder str = new StringBuilder(); str.Append(Type + "\t"); str.Append(Position + "\t"); str.Append(Attribute + "\t"); str.Append(Qualifier + "\t"); str.Append(PersonDegree + "\t"); str.Append(PersonGender + "\t"); str.Append(PersonNumber + "\t"); str.Append(Mood + "\t"); str.Append(Lemma.ToArabic() + "\t"); str.Append(Root.ToArabic() + "\t"); str.Append(SpecialGroup.ToArabic()); return(str.ToString()); }
public void add_to_bookmark(String bname, string lemmaName) { int lemmaid = new Lemma().getLemmaIDbyLemmaName(lemmaName); using (OleDbConnection myCon = new OleDbConnection(testadopse.Properties.Settings.Default.FinalConnectionString)) { OleDbCommand cmd = new OleDbCommand(); cmd.CommandType = CommandType.Text; cmd.CommandText = "insert into Bookmark (Bname,LemmaID) values (@param1,@param2)"; cmd.Parameters.AddWithValue("@param1", bname); cmd.Parameters.AddWithValue("@param2", lemmaid); cmd.Connection = myCon; myCon.Open(); cmd.ExecuteNonQuery(); System.Windows.Forms.MessageBox.Show("An Item has been successfully added", "Caption", MessageBoxButtons.OKCancel, MessageBoxIcon.Information); myCon.Close(); } }
public bool ConsistentWith(TaggedToken taggedToken) { if (PosTag >= 0 && taggedToken.PosTag >= 0 && PosTag != taggedToken.PosTag) { return(false); } if (Lemma != null && taggedToken.Lemma != null && !Lemma.Equals(taggedToken.Lemma)) { return(false); } if (NeTag >= 0 && taggedToken.NeTag >= 0 && NeTag != taggedToken.NeTag) { return(false); } return(NeTypeTag < 0 || taggedToken.NeTypeTag < 0 || NeTypeTag == taggedToken.NeTypeTag); }
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/ private void GetLemmas() { VM.LemmaList = new List <Lemma>(); VM.lemmaIDs = new List <int>(); List <Language> userLangs = new List <Language>(); StreamReader SR = new StreamReader(path); string line = SR.ReadLine(); while (line != null) { string[] arr = line.Split(','); VM.LemmaList.Add(Lemma.FromLine(line)); VM.lemmaIDs.Add(int.Parse(arr[0])); line = SR.ReadLine(); } SR.Close(); VM.LemmaList.Sort(); }
// // EVENT: Otan ginetai klik se ena lemmaname na emfanizei to lemma kai to periexomeno tou // public void label_Click(object sender, EventArgs e) { Label lbl = sender as Label; ViewLemma vl = new ViewLemma(); Lemma lmid = new Lemma(); panel2.Controls.Clear(); panel2.Controls.Add(vl); vl.Dock = DockStyle.Fill; vl.lemman.Text = lbl.Text; setlemmaname(lbl.Text); vl.lemmat.Text = lm.GetLemmaContent(lbl.Text); setlemmatext(vl.lemmat.Text); addhistory(lmid, lbl); // Epidh exei epilegei na anoiksei to label klisei tis methodou addhistory // des pio katw gia thn methodo . }
// Use this to Search public void SetRandomLemma() { // get a random lemma to display Lemma lemma = Random.getRandomLemma(); // configure the web browser document text accordingly string titleStyle = " style=\"display: block; " + "font-size: 3em;" + "margin-top: 0.67em; " + "margin-bottom: 0.67em; " + "margin-left: 0; " + "margin-right: 0; " + "font-weight: bold;\""; lemmaOfTheDayWebBrowser.DocumentText = "<h1" + titleStyle + ">" + lemma.Title.Replace("_", " ") + "</h1>" + Encoding.UTF8.GetString(lemma.Body); if (!StartPage.recentLemmata.Contains(lemma.Title)) { StartPage.recentLemmata.Add(lemma.Title); } }
private static void ConfigureLemma(int userID, string lemmaTitle, out Lemma lemma, out EditedLemma editedLemma) { byte[] lemmaBody = null; int lemmaCategory = -999; lemma = null; editedLemma = null; if (LemmaViewUserControl.Instance.Mode == 0) { //Get the properties needed for the creation of Lemma object lemmaBody = DBConnect.GetLemmaBodyByTitle(lemmaTitle); lemmaCategory = DBConnect.GetLemmaCategoryByTitle(lemmaTitle); lemma = new Lemma(lemmaTitle, lemmaBody, lemmaCategory); } else { User user = new User(); user.Id = userID; editedLemma = DBConnect.GetEditedLemmaByUserAndTitle(lemmaTitle, user); } }
public void ProcessDictionary(string filename, IEnumerable<IDictionaryProcessor> dictionaryProcessors) { using (XmlReader reader = new XmlTextReader(filename)) { bool openItem = true; Lemma currentLemma = null; // Loop the reader, till it cant read anymore while (reader.Read()) { // An object with the type Element was found. if (reader.NodeType == XmlNodeType.Element) { // Check name of the node and write the contents in the object accordingly. if (reader.Name == "lemma") { currentLemma = new Lemma(); openItem = true; } if (reader.NodeType == XmlNodeType.Element && reader.Name == "l" && openItem) { currentLemma.Text = reader.GetAttribute("t"); } if (reader.NodeType == XmlNodeType.Element && reader.Name == "f" && openItem) { currentLemma.Forms.Add(new LemmaForm(reader.GetAttribute("t"), new List<Grammem>())); } } // EndElement was found, check if it is named item, if it is, store the object in the list and set openItem to false. else if (reader.NodeType == XmlNodeType.EndElement && reader.Name == "lemma" && openItem) { openItem = false; foreach (IDictionaryProcessor dictionaryProcessor in dictionaryProcessors) { dictionaryProcessor.ProcessLemma(currentLemma); } } } } }
/// <summary> /// Convert method creates db file from wndb files /// dictpath - path to wndb data files /// context - dest db context /// </summary> public static void Convert(string dictPack, WordNetContext context) { WNDB wndb = new WNDB(dictPack); var synWords = new List <string>(); // int ind; var wordToLemma = new Dictionary <string, Lemma>(); var words = new Dictionary <string, Writing>(); var poses = (new [] { "n", "v", "a", "r" }).Select(s => PartOfSpeech.of(s)); foreach (var pos in poses) { Console.WriteLine("Process Data of {0}", pos.name); // ind = 0; foreach (var data in wndb.GetData(pos)) { if (data.pos != pos.symbol && !(data.pos == "s" && pos.symbol == "a")) //data.adj includes 'a' & 's' pos symbols { throw new Exception("pos!=data.pos"); } var synset = new SynSet { Pos = data.pos }; context.SynSets.Add(synset); synWords.Clear(); foreach (var oword in data.origWords) { Lemma lemma; string lcWord = oword.word.ToLower(); // add lemma if (!wordToLemma.TryGetValue(lcWord, out lemma)) { lemma = new Lemma { Value = lcWord, Poses = data.pos }; wordToLemma.Add(lcWord, lemma); context.Lemmas.Add(lemma); } else if (!lemma.Poses.Contains(data.pos)) { lemma.Poses += data.pos; } if (synWords.IndexOf(lcWord) < 0) { synWords.Add(lcWord); // add SynSet <-> Lemma relation context.SynsetLemmas.Add(new SynsetLemma { SynSet = synset, Lemma = lemma }); } // add original word if it differs from lemma Writing word; if (lcWord != oword.word) { if (!words.TryGetValue(oword.word, out word)) { word = new Writing { Value = oword.word, Lemma = lemma }; words.Add(oword.word, word); context.Writings.Add(word); } else if (word.Lemma != lemma) { Console.WriteLine("Word mix: {0} {1} {2}", oword.word, lemma.Value, word.Lemma.Value); continue; } } } synset.Definition = string.Join(";", data.definitions); synset.Example = string.Join(";", data.examples); // ind++; // if (ind % 1000 == 0) // ShowProgress(ind.ToString()); } Console.WriteLine("Save changes"); context.SaveChanges(); // exceptions //TODO: remove morphes, ... Console.WriteLine("Process Exceptions of {0}", pos.name); // ind = 0; foreach (var exwords in GetExceptions(wndb, pos)) { for (int i = 1; i < exwords.Length; i++) { if (exwords[i] == exwords[0]) { continue; } Lemma lemma; if (wordToLemma.TryGetValue(exwords[i], out lemma) || (exwords[i].Contains('-') && wordToLemma.TryGetValue(exwords[i].Replace('-', ' '), out lemma))) { context.Excepts.Add(new Except { Value = exwords[0], MainForm = exwords[i], Lemma = lemma }); } // else // { // Console.WriteLine("Lemma not found {0}", exwords[i]); // context.Excepts.Add(new Except { Value = exwords[0], MainForm = exwords[i] }); // } } // ind++; // if (ind % 1000 == 0) // ShowProgress(ind.ToString()); } Console.WriteLine("Save changes"); context.SaveChanges(); } //Console.WriteLine("Save changes"); context.SaveChanges(); }
public async Task <bool> AddLemmaAsync(Lemma lemma) { lemmas.Add(lemma); return(await Task.FromResult(true)); }
public static Lemma CopyLemma(Lemma oldLm) { return new Lemma(oldLm.tok, oldLm.Name, oldLm.HasStaticKeyword, oldLm.TypeArgs, oldLm.Ins, oldLm.Outs, oldLm.Req, oldLm.Mod, oldLm.Ens, oldLm.Decreases, oldLm.Body, oldLm.Attributes, oldLm.SignatureEllipsis); }
void MethodDecl(MemberModifiers mmod, bool allowConstructor, bool isWithinAbstractModule, out Method/*!*/ m) { Contract.Ensures(Contract.ValueAtReturn(out m) !=null); IToken/*!*/ id = Token.NoToken; bool hasName = false; IToken keywordToken; Attributes attrs = null; List<TypeParameter/*!*/>/*!*/ typeArgs = new List<TypeParameter/*!*/>(); List<Formal/*!*/> ins = new List<Formal/*!*/>(); List<Formal/*!*/> outs = new List<Formal/*!*/>(); List<MaybeFreeExpression/*!*/> req = new List<MaybeFreeExpression/*!*/>(); List<FrameExpression/*!*/> mod = new List<FrameExpression/*!*/>(); List<MaybeFreeExpression/*!*/> ens = new List<MaybeFreeExpression/*!*/>(); List<Expression/*!*/> dec = new List<Expression/*!*/>(); Attributes decAttrs = null; Attributes modAttrs = null; BlockStmt body = null; bool isLemma = false; bool isConstructor = false; bool isIndLemma = false; bool isCoLemma = false; IToken signatureEllipsis = null; IToken bodyStart = Token.NoToken; IToken bodyEnd = Token.NoToken; while (!(StartOf(10))) {SynErr(158); Get();} switch (la.kind) { case 84: { Get(); break; } case 41: { Get(); isLemma = true; break; } case 85: { Get(); isCoLemma = true; break; } case 86: { Get(); isCoLemma = true; errors.Warning(t, "the 'comethod' keyword has been deprecated; it has been renamed to 'colemma'"); break; } case 40: { Get(); Expect(41); isIndLemma = true; break; } case 87: { Get(); if (allowConstructor) { isConstructor = true; } else { SemErr(t, "constructors are allowed only in classes"); } break; } default: SynErr(159); break; } keywordToken = t; if (isLemma) { if (mmod.IsGhost) { SemErr(t, "lemmas cannot be declared 'ghost' (they are automatically 'ghost')"); } } else if (isConstructor) { if (mmod.IsGhost) { SemErr(t, "constructors cannot be declared 'ghost'"); } if (mmod.IsStatic) { SemErr(t, "constructors cannot be declared 'static'"); } } else if (isIndLemma) { if (mmod.IsGhost) { SemErr(t, "inductive lemmas cannot be declared 'ghost' (they are automatically 'ghost')"); } } else if (isCoLemma) { if (mmod.IsGhost) { SemErr(t, "colemmas cannot be declared 'ghost' (they are automatically 'ghost')"); } } while (la.kind == 46) { Attribute(ref attrs); } if (la.kind == 1) { NoUSIdent(out id); hasName = true; } if (!hasName) { id = keywordToken; if (!isConstructor) { SemErr(la, "a method must be given a name (expecting identifier)"); } } if (la.kind == 50 || la.kind == 52) { if (la.kind == 52) { GenericParameters(typeArgs); } Formals(true, !mmod.IsGhost, ins); if (la.kind == 83) { Get(); if (isConstructor) { SemErr(t, "constructors cannot have out-parameters"); } Formals(false, !mmod.IsGhost, outs); } } else if (la.kind == 59) { Get(); signatureEllipsis = t; } else SynErr(160); while (StartOf(11)) { MethodSpec(req, mod, ens, dec, ref decAttrs, ref modAttrs); } if (la.kind == 46) { BlockStmt(out body, out bodyStart, out bodyEnd); } if (!isWithinAbstractModule && DafnyOptions.O.DisallowSoundnessCheating && body == null && ens.Count > 0 && !Attributes.Contains(attrs, "axiom") && !Attributes.Contains(attrs, "imported") && !Attributes.Contains(attrs, "decl") && theVerifyThisFile) { SemErr(t, "a method with an ensures clause must have a body, unless given the :axiom attribute"); } IToken tok = theVerifyThisFile ? id : new IncludeToken(id); if (isConstructor) { m = new Constructor(tok, hasName ? id.val : "_ctor", typeArgs, ins, req, new Specification<FrameExpression>(mod, modAttrs), ens, new Specification<Expression>(dec, decAttrs), body, attrs, signatureEllipsis); } else if (isIndLemma) { m = new InductiveLemma(tok, id.val, mmod.IsStatic, typeArgs, ins, outs, req, new Specification<FrameExpression>(mod, modAttrs), ens, new Specification<Expression>(dec, decAttrs), body, attrs, signatureEllipsis); } else if (isCoLemma) { m = new CoLemma(tok, id.val, mmod.IsStatic, typeArgs, ins, outs, req, new Specification<FrameExpression>(mod, modAttrs), ens, new Specification<Expression>(dec, decAttrs), body, attrs, signatureEllipsis); } else if (isLemma) { m = new Lemma(tok, id.val, mmod.IsStatic, typeArgs, ins, outs, req, new Specification<FrameExpression>(mod, modAttrs), ens, new Specification<Expression>(dec, decAttrs), body, attrs, signatureEllipsis); } else { m = new Method(tok, id.val, mmod.IsStatic, mmod.IsGhost, typeArgs, ins, outs, req, new Specification<FrameExpression>(mod, modAttrs), ens, new Specification<Expression>(dec, decAttrs), body, attrs, signatureEllipsis); } m.BodyStartTok = bodyStart; m.BodyEndTok = bodyEnd; }
public async Task <bool> UpdateLemmaAsync(Lemma lemma) { return(await Task.FromResult(true)); }
public async Task <bool> AcceptLemmaAsync(Lemma item) { return(await Task.FromResult(true)); }
private void AddVariant(Statement st, ref List <Solution> solution_list) { List <Expression> call_arguments = null; List <Expression> dec_list = null; Expression input = null; InitArgs(st, out call_arguments); Contract.Assert(tcce.OfSize(call_arguments, 1), Util.Error.MkErr(st, 0, 1, call_arguments.Count)); StringLiteralExpr wildCard = call_arguments[0] as StringLiteralExpr; if (wildCard != null) { if (wildCard.Value.Equals("*")) { input = new WildcardExpr(wildCard.tok); } } else { // hack /* * TODO: * Implement propper variable replacement */ object tmp; ProcessArg(call_arguments[0], out tmp); Contract.Assert(tmp != null); IVariable form = tmp as IVariable; if (form != null) { input = new NameSegment(form.Tok, form.Name, null); } else if (tmp is BinaryExpr) { input = tmp as BinaryExpr; } else if (tmp is NameSegment) { input = tmp as NameSegment; } } WhileStmt ws = FindWhileStmt(globalContext.tac_call, globalContext.md); if (ws != null) { WhileStmt nws = null; dec_list = new List <Expression>(ws.Decreases.Expressions.ToArray()); dec_list.Add(input); Specification <Expression> decreases = new Specification <Expression>(dec_list, ws.Attributes); nws = new WhileStmt(ws.Tok, ws.EndTok, ws.Guard, ws.Invariants, decreases, ws.Mod, ws.Body); AddUpdated(ws, nws); } else { Method target = Program.FindMember(globalContext.program.ParseProgram(), localContext.md.Name) as Method; if (GetNewTarget() != null && GetNewTarget().Name == target.Name) { target = GetNewTarget(); } Contract.Assert(target != null, Util.Error.MkErr(st, 3)); dec_list = target.Decreases.Expressions; // insert new variants at the end of the existing variants list Contract.Assert(input != null); dec_list.Add(input); Specification <Expression> decreases = new Specification <Expression>(dec_list, target.Decreases.Attributes); Method result = null; dynamic lemma = null; if ((lemma = target as Lemma) != null) { result = new Lemma(lemma.tok, lemma.Name, lemma.HasStaticKeyword, lemma.TypeArgs, lemma.Ins, lemma.Outs, lemma.Req, lemma.Mod, lemma.Ens, decreases, lemma.Body, lemma.Attributes, lemma.SignatureEllipsis); } else if ((lemma = target as CoLemma) != null) { result = new CoLemma(lemma.tok, lemma.Name, lemma.HasStaticKeyword, lemma.TypeArgs, lemma.Ins, lemma.Outs, lemma.Req, lemma.Mod, lemma.Ens, decreases, lemma.Body, lemma.Attributes, lemma.SignatureEllipsis); } else { result = new Method(target.tok, target.Name, target.HasStaticKeyword, target.IsGhost, target.TypeArgs, target.Ins, target.Outs, target.Req, target.Mod, target.Ens, decreases, target.Body, target.Attributes, target.SignatureEllipsis); } // register new method this.localContext.new_target = result; globalContext.program.IncTotalBranchCount(globalContext.program.currentDebug); } solution_list.Add(new Solution(this.Copy())); }
public IActionResult Edit(Lemma editLemma) { EditLemma(editLemma); return(RedirectToAction("Index")); }
/*----------------------------------------------------------------------------*/ private void DeleteLemma(int deleteID) { Lemma delLemma = VM.LemmaList.Find(l => l.id == deleteID); VM.LemmaList.Remove(delLemma); }
private void AddVariant(Statement st, ref List<Solution> solution_list) { List<Expression> call_arguments = null; List<Expression> dec_list = null; Expression input = null; InitArgs(st, out call_arguments); Contract.Assert(tcce.OfSize(call_arguments, 1), Util.Error.MkErr(st, 0, 1, call_arguments.Count)); StringLiteralExpr wildCard = call_arguments[0] as StringLiteralExpr; if (wildCard != null) { if (wildCard.Value.Equals("*")) input = new WildcardExpr(wildCard.tok); } else { // hack /* * TODO: * Implement propper variable replacement */ object tmp; ProcessArg(call_arguments[0], out tmp); Contract.Assert(tmp != null); IVariable form = tmp as IVariable; if (form != null) input = new NameSegment(form.Tok, form.Name, null); else if (tmp is BinaryExpr) { input = tmp as BinaryExpr; } else if (tmp is NameSegment) { input = tmp as NameSegment; } } WhileStmt ws = FindWhileStmt(globalContext.tac_call, globalContext.md); if (ws != null) { WhileStmt nws = null; dec_list = new List<Expression>(ws.Decreases.Expressions.ToArray()); dec_list.Add(input); Specification<Expression> decreases = new Specification<Expression>(dec_list, ws.Attributes); nws = new WhileStmt(ws.Tok, ws.EndTok, ws.Guard, ws.Invariants, decreases, ws.Mod, ws.Body); AddUpdated(ws, nws); } else { Method target = Program.FindMember(globalContext.program.ParseProgram(), localContext.md.Name) as Method; if (GetNewTarget() != null && GetNewTarget().Name == target.Name) target = GetNewTarget(); Contract.Assert(target != null, Util.Error.MkErr(st, 3)); dec_list = target.Decreases.Expressions; // insert new variants at the end of the existing variants list Contract.Assert(input != null); dec_list.Add(input); Specification<Expression> decreases = new Specification<Expression>(dec_list, target.Decreases.Attributes); Method result = null; dynamic lemma = null; if ((lemma = target as Lemma) != null) { result = new Lemma(lemma.tok, lemma.Name, lemma.HasStaticKeyword, lemma.TypeArgs, lemma.Ins, lemma.Outs, lemma.Req, lemma.Mod, lemma.Ens, decreases, lemma.Body, lemma.Attributes, lemma.SignatureEllipsis); } else if ((lemma = target as CoLemma) != null) { result = new CoLemma(lemma.tok, lemma.Name, lemma.HasStaticKeyword, lemma.TypeArgs, lemma.Ins, lemma.Outs, lemma.Req, lemma.Mod, lemma.Ens, decreases, lemma.Body, lemma.Attributes, lemma.SignatureEllipsis); } else result = new Method(target.tok, target.Name, target.HasStaticKeyword, target.IsGhost, target.TypeArgs, target.Ins, target.Outs, target.Req, target.Mod, target.Ens, decreases, target.Body, target.Attributes, target.SignatureEllipsis); // register new method this.localContext.new_target = result; globalContext.program.IncTotalBranchCount(globalContext.program.currentDebug); } solution_list.Add(new Solution(this.Copy())); }
void MethodDecl(DeclModifierData dmod, bool allowConstructor, bool isWithinAbstractModule, out Method/*!*/ m) { Contract.Ensures(Contract.ValueAtReturn(out m) !=null); IToken/*!*/ id = Token.NoToken; bool hasName = false; IToken keywordToken; Attributes attrs = null; List<TypeParameter/*!*/>/*!*/ typeArgs = new List<TypeParameter/*!*/>(); List<Formal/*!*/> ins = new List<Formal/*!*/>(); List<Formal/*!*/> outs = new List<Formal/*!*/>(); List<MaybeFreeExpression/*!*/> req = new List<MaybeFreeExpression/*!*/>(); List<FrameExpression/*!*/> mod = new List<FrameExpression/*!*/>(); List<MaybeFreeExpression/*!*/> ens = new List<MaybeFreeExpression/*!*/>(); List<Expression/*!*/> dec = new List<Expression/*!*/>(); Attributes decAttrs = null; Attributes modAttrs = null; BlockStmt body = null; bool isLemma = false; bool isConstructor = false; bool isIndLemma = false; bool isCoLemma = false; bool isTactic = false; IToken signatureEllipsis = null; IToken bodyStart = Token.NoToken; IToken bodyEnd = Token.NoToken; AllowedDeclModifiers allowed = AllowedDeclModifiers.None; string caption = ""; while (!(StartOf(12))) {SynErr(172); Get();} switch (la.kind) { case 89: { Get(); caption = "Methods"; allowed = AllowedDeclModifiers.Ghost | AllowedDeclModifiers.Static | AllowedDeclModifiers.Extern; break; } case 60: { Get(); isTactic = true; caption = "Tactics"; allowed = AllowedDeclModifiers.AlreadyGhost | AllowedDeclModifiers.Static | AllowedDeclModifiers.Protected; break; } case 41: { Get(); isLemma = true; caption = "Lemmas"; allowed = AllowedDeclModifiers.AlreadyGhost | AllowedDeclModifiers.Static | AllowedDeclModifiers.Protected; break; } case 90: { Get(); isCoLemma = true; caption = "Colemmas"; allowed = AllowedDeclModifiers.AlreadyGhost | AllowedDeclModifiers.Static | AllowedDeclModifiers.Protected; break; } case 91: { Get(); isCoLemma = true; caption = "Comethods"; allowed = AllowedDeclModifiers.AlreadyGhost | AllowedDeclModifiers.Static | AllowedDeclModifiers.Protected; errors.Warning(t, "the 'comethod' keyword has been deprecated; it has been renamed to 'colemma'"); break; } case 40: { Get(); Expect(41); isIndLemma = true; caption = "Inductive lemmas"; allowed = AllowedDeclModifiers.AlreadyGhost | AllowedDeclModifiers.Static; break; } case 92: { Get(); if (allowConstructor) { isConstructor = true; } else { SemErr(t, "constructors are allowed only in classes"); } caption = "Constructors"; allowed = AllowedDeclModifiers.None; break; } default: SynErr(173); break; } keywordToken = t; CheckDeclModifiers(dmod, caption, allowed); while (la.kind == 46) { Attribute(ref attrs); } if (la.kind == 1) { NoUSIdent(out id); hasName = true; } if (!hasName) { id = keywordToken; if (!isConstructor) { SemErr(la, "a method must be given a name (expecting identifier)"); } } EncodeExternAsAttribute(dmod, ref attrs, id, /* needAxiom */ true); if (la.kind == 50 || la.kind == 52) { if (la.kind == 52) { GenericParameters(typeArgs); } Formals(true, !dmod.IsGhost, ins); if (la.kind == 88) { Get(); if (isConstructor) { SemErr(t, "constructors cannot have out-parameters"); } Formals(false, !dmod.IsGhost, outs); } } else if (la.kind == 59) { Get(); signatureEllipsis = t; } else SynErr(174); while (StartOf(13)) { MethodSpec(req, mod, ens, dec, ref decAttrs, ref modAttrs); } if (la.kind == 46) { BlockStmt(out body, out bodyStart, out bodyEnd); } if (!isWithinAbstractModule && DafnyOptions.O.DisallowSoundnessCheating && body == null && ens.Count > 0 && !Attributes.Contains(attrs, "axiom") && !Attributes.Contains(attrs, "imported") && !Attributes.Contains(attrs, "decl") && theVerifyThisFile) { SemErr(t, "a method with an ensures clause must have a body, unless given the :axiom attribute"); } IToken tok = theVerifyThisFile ? id : new IncludeToken(id); if (isConstructor) { m = new Constructor(tok, hasName ? id.val : "_ctor", typeArgs, ins, req, new Specification<FrameExpression>(mod, modAttrs), ens, new Specification<Expression>(dec, decAttrs), body, attrs, signatureEllipsis); } else if (isIndLemma) { m = new InductiveLemma(tok, id.val, dmod.IsStatic, typeArgs, ins, outs, req, new Specification<FrameExpression>(mod, modAttrs), ens, new Specification<Expression>(dec, decAttrs), body, attrs, signatureEllipsis); } else if (isCoLemma) { m = new CoLemma(tok, id.val, dmod.IsStatic, typeArgs, ins, outs, req, new Specification<FrameExpression>(mod, modAttrs), ens, new Specification<Expression>(dec, decAttrs), body, attrs, signatureEllipsis); } else if (isLemma) { m = new Lemma(tok, id.val, dmod.IsStatic, typeArgs, ins, outs, req, new Specification<FrameExpression>(mod, modAttrs), ens, new Specification<Expression>(dec, decAttrs), body, attrs, signatureEllipsis); } else if(isTactic) { m = new Tactic(tok, id.val, dmod.IsStatic, typeArgs, ins, outs, req, new Specification<FrameExpression>(mod, modAttrs), ens, new Specification<Expression>(dec, decAttrs), body, attrs, signatureEllipsis); } else { m = new Method(tok, id.val, dmod.IsStatic, dmod.IsGhost, typeArgs, ins, outs, req, new Specification<FrameExpression>(mod, modAttrs), ens, new Specification<Expression>(dec, decAttrs), body, attrs, signatureEllipsis); } m.BodyStartTok = bodyStart; m.BodyEndTok = bodyEnd; }