Skip to content
Snippets Groups Projects
Fact.cs 146 KiB
Newer Older
  • Learn to ignore specific revisions
  •         this.Cid = cid;
            this._URI = uri;
            _ = this.Label;
        }
    
        /// \copydoc Fact.parseFact(Scroll.ScrollFact)
        public new static OnCircleFact parseFact(Scroll.ScrollFact fact)
        {
            string uri = fact.@ref.uri;
    
            OMA tp = (OMA)((Scroll.ScrollSymbolFact)fact).tp;
            if (tp == null)
                return null;
    
            string circleUri = ((OMS)((OMA)((OMA)((Scroll.ScrollSymbolFact)fact).tp).arguments[0]).arguments[0]).uri;
            string pointUri = ((OMS)((OMA)((OMA)((Scroll.ScrollSymbolFact)fact).tp).arguments[0]).arguments[1]).uri;
           
            if (StageStatic.stage.factState.ContainsKey(pointUri)
             && StageStatic.stage.factState.ContainsKey(circleUri))
                return new OnCircleFact(pointUri, circleUri, uri, StageStatic.stage.factState);
    
            //If dependent facts do not exist return null
            else
                return null;
        }
    
        /// \copydoc Fact.generateLabel
        protected override string generateLabel()
        {
            return _Facts[Pid].Label + "∈" + _Facts[Cid].Label;
        }
    
        /// \copydoc Fact.hasDependentFacts
        public override Boolean hasDependentFacts()
        {
            return true;
        }
    
        /// \copydoc Fact.getDependentFactIds
        public override string[] getDependentFactIds()
        {
            return new string[] { Pid, Cid };
        }
    
        /// \copydoc Fact.instantiateDisplay(GameObject, Transform)
        public override GameObject instantiateDisplay(GameObject prefab, Transform transform)
        {
            var obj = GameObject.Instantiate(prefab, Vector3.zero, Quaternion.identity, transform);
            obj.transform.GetChild(0).gameObject.GetComponent<TextMeshProUGUI>().text = _Facts[this.Pid].Label + "∈" + _Facts[this.Cid].Label;
            obj.GetComponent<FactWrapper>().fact = this;
    
            return obj;
        }
    
        /// \copydoc Fact.GetHashCode
        public override int GetHashCode()
        {
            return this.Pid.GetHashCode() ^ this.Cid.GetHashCode();
        }
    
        /// \copydoc Fact.Equivalent(Fact, Fact)
        protected override bool EquivalentWrapped(OnCircleFact c1, OnCircleFact c2)
        {
            if (c1.Pid == c2.Pid && c1.Cid == c2.Pid)
                return true;
    
            PointFact pc1 = (PointFact)_Facts[c1.Pid];
            CircleFact cc1 = (CircleFact)_Facts[c1.Cid];
    
            PointFact pc2 = (PointFact)_Facts[c2.Pid];
            CircleFact cc2 = (CircleFact)_Facts[c2.Cid];
    
            return pc1.Equivalent(pc2) && cc1.Equivalent(cc2);
        }
    }
    
    
    
    /// <summary>
    
    /// Angle comprised of a line and a circle 
    
    /// </summary>
    public class AngleCircleLineFact : FactWrappedCRTP<AngleCircleLineFact>
    {
        /// @{ <summary>
    
        /// One <see cref="Fact.Id">Id</see> of a <see cref="RayFact">RayFact</see> and a <see cref="CircleFact">CircleFact</see>  defining Angle [<see cref="Cid1"/>, <see cref="Rid2"/>].
    
        /// </summary>
        public string Cid1, Rid2;
        /// @}
        float angle;
    
        /// <summary> \copydoc Fact.Fact </summary>
        public AngleCircleLineFact() : base()
        {
            this.Cid1 = null;
            this.Rid2 = null;
            this.angle = 0.0f;
        }
    
        /// <summary>
        /// Copies <paramref name="fact"/> by initiating new MMT %Fact.
        /// </summary>
        /// <param name="fact">Fact to be copied</param>
        /// <param name="old_to_new"><c>Dictionary</c> mapping <paramref name="fact"/>.<see cref="getDependentFactIds"/> in <paramref name="fact"/>.<see cref="Fact._Facts"/> to corresponding <see cref="Fact.Id"/> in <paramref name="organizer"/> </param>
        /// <param name="organizer">sets <see cref="_Facts"/></param>
        public AngleCircleLineFact(AngleCircleLineFact fact, Dictionary<string, string> old_to_new, FactOrganizer organizer) : base(fact, organizer)
        {
            init(old_to_new[fact.Cid1], old_to_new[fact.Rid2], fact.angle);
        }
    
        /// <summary>
        /// Standard Constructor
        /// </summary>
    
        /// <param name="cid1">sets <see cref="Cid1"/></param>
        /// <param name="rid2">sets <see cref="Rid2"/></param>
        /// <param name="angle"> sets the angle </param>
    
        /// <param name="organizer">sets <see cref="Fact._Facts"/></param>
        public AngleCircleLineFact(string cid1, string rid2, float angle, FactOrganizer organizer) : base(organizer)
        {
            init(cid1, rid2, angle);
        }
    
        /// <summary>
    
        /// Initiates <see cref="Cid1"/>, <see cref="Rid2"/>, <see cref="angle"/> <see cref="Fact._URI"/> and creates MMT %Fact Server-Side
    
        /// <param name="cid1">sets <see cref="Cid1"/></param>
        /// <param name="rid2">sets <see cref="Rid2"/></param>
        /// <param name="angle"> sets the angle </param>
    
        private void init(string cid1, string rid2, float angle)
        {
            this.Cid1 = cid1;
            this.Rid2 = rid2;
            this.angle = angle;
    
            CircleFact cf1 = _Facts[cid1] as CircleFact;
            RayFact rf2 = _Facts[rid2] as RayFact;
            MMTDeclaration mmtDecl;
            string c1URI = cf1.Id;
            string r2URI = rf2.Id;
           
            if (Mathf.Abs(Mathf.Abs(angle) - 90.0f) < 0.1) {
                // also generate an orthogonal circle line fact
                OrthogonalCircleLineFact orthofact = new OrthogonalCircleLineFact(cid1, rid2, StageStatic.stage.factState);
                bool exists;
                StageStatic.stage.factState.Add(orthofact, out exists, true );
            }
    
            mmtDecl = generateMMTDeclaration(angle, c1URI, r2URI);
    
            AddFactResponse.sendAdd(mmtDecl, out this._URI);
        }
    
        /// <summary>
        /// Bypasses initialization of new MMT %Fact by using existend URI, _which is not checked for existence_.
        /// </summary>
    
        /// <param name="Cid1">sets <see cref="Cid1"/></param>
        /// <param name="´Rid2">sets <see cref="Rid2"/></param>
        /// <param name="angle"> sets the angle </param>
    
        /// <param name="backendURI">MMT URI</param>
        /// <param name="organizer">sets <see cref="Fact._Facts"/></param>
        public AngleCircleLineFact(string Cid1, string Rid2, float angle, string backendURI, FactOrganizer organizer) : base(organizer)
        {
            this.Cid1 = Cid1;
            this.Rid2 = Rid2;
            this.angle = angle;
    
            if (Mathf.Abs(Mathf.Abs(angle) - 90.0f) < 0.1)
            {
                // also generate an orthogonal circle line fact
                OrthogonalCircleLineFact orthofact = new OrthogonalCircleLineFact(Cid1, Rid2, StageStatic.stage.factState);
                bool exists;
                StageStatic.stage.factState.Add(orthofact, out exists, true);
            }
    
            this._URI = backendURI;
            _ = this.Label;
        }
    
        /// \copydoc Fact.parseFact(Scroll.ScrollFact)
        public new static AngleCircleLineFact parseFact(Scroll.ScrollFact fact)
        {
            string uri = fact.@ref.uri;
            string
                CircleUri,
                RayUri;
    
            OMA df = (OMA)((Scroll.ScrollValueFact)fact).lhs;
    
            if (df == null)
                return null;
    
            // init it with 0 degrees, so we don't accidentally generate orthogonalfacts 
            // and the parsing works correctly if smb ever adds a scroll for this
            float angle = 0.0f;
    
            if((((Scroll.ScrollValueFact)fact).value)!=null)
                angle = ((OMF)(((Scroll.ScrollValueFact)fact).value)).f;
    
    
            CircleUri = ((OMS)((OMA)((Scroll.ScrollValueFact)fact).lhs).arguments[0]).uri;
            RayUri = ((OMS)((OMA)((Scroll.ScrollValueFact)fact).lhs).arguments[1]).uri;
    
            if (StageStatic.stage.factState.ContainsKey(CircleUri)
             && StageStatic.stage.factState.ContainsKey(RayUri))
            {
                return new AngleCircleLineFact(CircleUri, RayUri, angle, uri, StageStatic.stage.factState);
            }
            else
            {
                //If dependent facts do not exist return null
                return null;
            }
        }
    
        /// \copydoc Fact.generateLabel
        protected override string generateLabel()
        {
            return  "∠" + _Facts[Cid1].Label + _Facts[Rid2].Label;
        }
    
        /// <summary>
        /// Constructs struct for not-right-angled MMT %Fact <see cref="AddFactResponse"/>
        /// </summary>
        /// <param name="val">Angle != 90f, _not checked_</param>
    
        /// <param name="c1URI"><see cref="Cid1"/></param>
        /// <param name="R2URI"><see cref="Rid2"/></param>
        /// <param name="val"><see cref="angle"/></param>
    
        /// <returns>struct for <see cref="AddFactResponse"/></returns>
        private MMTDeclaration generateMMTDeclaration(float val, string c1URI, string r2URI)
        {
            MMTTerm lhs =
                new OMA(
                    new OMS(MMTURIs.AnglePlaneLine),
                    new List<MMTTerm> {
                        new OMS(c1URI),
                        new OMS(r2URI),
                    }
                );
    
            MMTTerm valueTp = new OMS(MMTURIs.RealLit);
            MMTTerm value = new OMF(val);
    
            return new MMTValueDeclaration(this.Label, lhs, valueTp, value);
        }
    
        /// \copydoc Fact.hasDependentFacts
        public override Boolean hasDependentFacts()
        {
            return true;
        }
    
        /// \copydoc Fact.getDependentFactIds
        public override string[] getDependentFactIds()
        {
            return new string[] { Cid1, Rid2 };
        }
    
        /// \copydoc Fact.instantiateDisplay(GameObject, Transform)
        public override GameObject instantiateDisplay(GameObject prefab, Transform transform)
        {
            var obj = GameObject.Instantiate(prefab, Vector3.zero, Quaternion.identity, transform);
            obj.transform.GetChild(0).gameObject.GetComponent<TextMeshProUGUI>().text = _Facts[this.Cid1].Label;
            obj.transform.GetChild(1).gameObject.GetComponent<TextMeshProUGUI>().text = _Facts[this.Rid2].Label;
            obj.GetComponent<FactWrapper>().fact = this;
            return obj;
        }
    
        /// \copydoc Fact.GetHashCode
        public override int GetHashCode()
        {
            return this.Cid1.GetHashCode() ^ this.Rid2.GetHashCode();
        }
    
        /// \copydoc Fact.Equivalent(Fact, Fact)
        protected override bool EquivalentWrapped(AngleCircleLineFact f1, AngleCircleLineFact f2)
        {
            if (f1.Cid1 == f2.Cid1 && f1.Rid2 == f2.Rid2 )
                return true;
    
            CircleFact c1f1 = (CircleFact)_Facts[f1.Cid1];
            RayFact r2f1 = (RayFact)_Facts[f1.Rid2];
    
            CircleFact c1f2 = (CircleFact)_Facts[f2.Cid1];
            RayFact r2f2 = (RayFact)_Facts[f2.Rid2];
    
            return (c1f1.Equivalent(c1f2) && r2f1.Equivalent(r2f2));
        }
    }
    
    
    /// <summary>
    /// A RadiusFact that corresponds to a <see cref="CircleFact">PointFacts</see> and has a float value (the actual radius).
    /// </summary>
    public class RadiusFact : FactWrappedCRTP<RadiusFact>
    {
        ///  <summary> The circle corresponding to the radius </summary>
        public string Cid1;
        ///  <summary> The radius as a float </summary>
        public float rad;
    
        /// <summary> \copydoc Fact.Fact </summary>
        public RadiusFact() : base()
        {
            this.Cid1 = null;
            this.rad = 0.0f;
    
        }
    
        /// <summary>
        /// Copies <paramref name="fact"/> by initiating new MMT %Fact.
        /// </summary>
        /// <param name="fact">Fact to be copied</param>
        /// <param name="old_to_new"><c>Dictionary</c> mapping <paramref name="fact"/>.<see cref="getDependentFactIds"/> in <paramref name="fact"/>.<see cref="Fact._Facts"/> to corresponding <see cref="Fact.Id"/> in <paramref name="organizer"/> </param>
        /// <param name="organizer">sets <see cref="_Facts"/></param>
        public RadiusFact(RadiusFact fact, Dictionary<string, string> old_to_new, FactOrganizer organizer) : base(fact, organizer)
        {
            init(old_to_new[fact.Cid1]);
        }
    
        /// <summary>
        /// Standard Constructor
        /// </summary>
        /// <param name="cid1">sets <see cref="Cid1"/></param>
        /// <param name="organizer">sets <see cref="Fact._Facts"/></param>
        public RadiusFact(string cid1, FactOrganizer organizer) : base(organizer)
        {
            init(cid1);
        }
    
        /// <summary>
        /// Initiates <see cref="Cid1"/> and <see cref="rad"/>
        /// </summary>
        /// <param name="cid1">sets <see cref="Cid1"/></param>
        private void init(string cid1)
        {
            this.Cid1 = cid1;
    
            CircleFact cf1 = _Facts[cid1] as CircleFact;
            this.rad = cf1.radius;
    
    
            MMTDeclaration mmtDecl;
            string c1URI = cf1.Id;
    
    
            mmtDecl = generateMMTDeclaration(c1URI,this.rad);
    
            AddFactResponse.sendAdd(mmtDecl,  out this._URI);
        }
    
        /// <summary>
        /// Bypasses initialization of new MMT %Fact by using existend URI, _which is not checked for existence_.
        /// </summary>
    
        /// <param name="Cid1">sets <see cref="Cid1"/></param>
    
    2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653
        /// <param name="backendURI">MMT URI</param>
        /// <param name="organizer">sets <see cref="Fact._Facts"/></param>
        public RadiusFact(string Cid1, string backendURI, FactOrganizer organizer) : base(organizer)
        {
            this.Cid1 = Cid1;
    
            this._URI = backendURI;
            _ = this.Label;
        }
    
        /// \copydoc Fact.parseFact(Scroll.ScrollFact)
        public new static RadiusFact parseFact(Scroll.ScrollFact fact)
        {
            string uri = fact.@ref.uri;
            string CircleUri = ((OMS)((OMA)((Scroll.ScrollValueFact)fact).lhs).arguments[0]).uri;
    
            if (StageStatic.stage.factState.ContainsKey(CircleUri))
    
                return new RadiusFact(CircleUri, uri, StageStatic.stage.factState);
    
            else    //If dependent facts do not exist return null
                return null;
        }
    
        /// \copydoc Fact.generateLabel
        protected override string generateLabel()
        {
            return "r "+ _Facts[Cid1].Label;
        }
    
        /// <summary>
        /// Constructs struct for not-right-angled MMT %Fact <see cref="AddFactResponse"/>
        /// </summary>
        /// <param name="rad"> see <see cref="rad"/></param>
        /// <param name="c1URI"> see <see cref="Cid1"/></param>
    
        /// <returns>struct for <see cref="AddFactResponse"/></returns>
        private MMTDeclaration generateMMTDeclaration( string c1URI, float rad)
        {
            MMTTerm lhs =
                new OMA(
                    new OMS(MMTURIs.RadiusCircleMetric),
                    new List<MMTTerm> {
                        new OMS(c1URI),
                    }
                );
    
            MMTTerm valueTp = new OMS(MMTURIs.RealLit);
            MMTTerm value = new OMF(rad);
    
            return new MMTValueDeclaration(this.Label, lhs, valueTp, value);
        }
    
        /// \copydoc Fact.hasDependentFacts
        public override Boolean hasDependentFacts()
        {
            return true;
        }
    
        /// \copydoc Fact.getDependentFactIds
        public override string[] getDependentFactIds()
        {
            return new string[] { Cid1};
        }
    
        /// \copydoc Fact.instantiateDisplay(GameObject, Transform)
        public override GameObject instantiateDisplay(GameObject prefab, Transform transform)
        {
            var obj = GameObject.Instantiate(prefab, Vector3.zero, Quaternion.identity, transform);
            obj.transform.GetChild(0).gameObject.GetComponent<TextMeshProUGUI>().text = "r: "+_Facts[this.Cid1].Label;
            obj.GetComponent<FactWrapper>().fact = this;
            return obj;
        }
    
        /// \copydoc Fact.GetHashCode
        public override int GetHashCode()
        {
            return this.Cid1.GetHashCode();
        }
    
        /// \copydoc Fact.Equivalent(Fact, Fact)
        protected override bool EquivalentWrapped(RadiusFact f1, RadiusFact f2)
        {
            if (f1.Cid1 == f2.Cid1)
                return true;
    
            CircleFact c1f1 = (CircleFact)_Facts[f1.Cid1];
    
            CircleFact c1f2 = (CircleFact)_Facts[f2.Cid1];
            // if they correspond to the same circle, then automatically the radius has to be the same
    
            return (c1f1.Equivalent(c1f2));
        }
    }
    
    
    /// <summary>
    /// Area of a <see cref="CircleFact">CircleFact</see> 
    /// </summary>
    public class AreaCircleFact : FactWrappedCRTP<AreaCircleFact>
    {
       /// <summary> the circle <see cref="CircleFact">CircleFact</see>  </summary>
        public string Cid1;
        /// <summary> the area which is contained by the circle </summary>
        public float A;
    
    
    
        /// <summary> \copydoc Fact.Fact </summary>
        public AreaCircleFact() : base()
        {
            this.Cid1 = null;
            this.A = 0.0f;
    
        }
    
        /// <summary>
        /// Copies <paramref name="fact"/> by initiating new MMT %Fact.
        /// </summary>
        /// <param name="fact">Fact to be copied</param>
        /// <param name="old_to_new"><c>Dictionary</c> mapping <paramref name="fact"/>.<see cref="getDependentFactIds"/> in <paramref name="fact"/>.<see cref="Fact._Facts"/> to corresponding <see cref="Fact.Id"/> in <paramref name="organizer"/> </param>
        /// <param name="organizer">sets <see cref="_Facts"/></param>
        public AreaCircleFact(AreaCircleFact fact, Dictionary<string, string> old_to_new, FactOrganizer organizer) : base(fact, organizer)
        {
            init(old_to_new[fact.Cid1]);
        }
    
        /// <summary>
        /// Standard Constructor
        /// </summary>
        /// <param name="cid1">sets <see cref="Cid1"/></param>
        /// <param name="organizer">sets <see cref="Fact._Facts"/></param>
        public AreaCircleFact(string cid1, FactOrganizer organizer) : base(organizer)
        {
            init(cid1);
        }
    
        /// <summary>
        /// Initiates <see cref="Cid1"/> and creates MMT %Fact Server-Side
        /// </summary>
        /// <param name="cid1">sets <see cref="Cid1"/></param>
    
        private void init(string cid1)
        {
            this.Cid1 = cid1;
    
            CircleFact cf1 = _Facts[cid1] as CircleFact;
            this.A = cf1.radius * cf1.radius * ( (float) Math.PI );
    
    
            MMTDeclaration mmtDecl;
            string c1URI = cf1.Id;
    
    
            mmtDecl = generateMMTDeclaration(c1URI, this.A);
    
            AddFactResponse.sendAdd(mmtDecl, out this._URI);
        }
    
        /// <summary>
        /// Bypasses initialization of new MMT %Fact by using existend URI, _which is not checked for existence_.
        /// </summary>
        /// <param name="Cid1">sets <see cref="Cid1"/></param>
        /// <param name="backendURI">MMT URI</param>
        /// <param name="organizer">sets <see cref="Fact._Facts"/></param>
        public AreaCircleFact(string Cid1, string backendURI, FactOrganizer organizer) : base(organizer)
        {
            this.Cid1 = Cid1;
    
            this._URI = backendURI;
            _ = this.Label;
        }
    
        /// \copydoc Fact.parseFact(Scroll.ScrollFact)
        public new static AreaCircleFact parseFact(Scroll.ScrollFact fact)
        {
            string uri = fact.@ref.uri;
            string CircleUri = ((OMS)((OMA)((Scroll.ScrollValueFact)fact).lhs).arguments[0]).uri;
    
            if (StageStatic.stage.factState.ContainsKey(CircleUri))
                return new AreaCircleFact(CircleUri, uri, StageStatic.stage.factState);
            else    //If dependent facts do not exist return null
                return null;
        }
    
        /// \copydoc Fact.generateLabel
        protected override string generateLabel()
        {
            return "A(" + _Facts[Cid1].Label+")";
        }
    
    
        /// <summary>
        /// Constructs a response, that is sent to the MMT-Server
        /// </summary>
        /// <param name="area"> area of the circle </param>
        /// <param name="c1URI">  <see cref="Cid1"/></param>
        /// <returns>struct for <see cref="AddFactResponse"/></returns>
        private MMTDeclaration generateMMTDeclaration(string c1URI, float area)
        {
            MMTTerm lhs =
                new OMA(
                    new OMS(MMTURIs.AreaCircle),
                    new List<MMTTerm> {
                        new OMS(c1URI),
                    }
                );
    
            MMTTerm valueTp = new OMS(MMTURIs.RealLit);
            MMTTerm value = new OMF(area);
    
            return new MMTValueDeclaration(this.Label, lhs, valueTp, value);
        }
    
        /// \copydoc Fact.hasDependentFacts
        public override Boolean hasDependentFacts()
        {
            return true;
        }
    
        /// \copydoc Fact.getDependentFactIds
        public override string[] getDependentFactIds()
        {
            return new string[] { Cid1 };
        }
    
        /// \copydoc Fact.instantiateDisplay(GameObject, Transform)
        public override GameObject instantiateDisplay(GameObject prefab, Transform transform)
        {
            var obj = GameObject.Instantiate(prefab, Vector3.zero, Quaternion.identity, transform);
            obj.transform.GetChild(0).gameObject.GetComponent<TextMeshProUGUI>().text = _Facts[this.Cid1].Label;
            obj.GetComponent<FactWrapper>().fact = this;
            return obj;
        }
    
        /// \copydoc Fact.GetHashCode
        /// is this a problem?
        public override int GetHashCode()
        {
            return this.Cid1.GetHashCode();
        }
    
        /// \copydoc Fact.Equivalent(Fact, Fact)
        protected override bool EquivalentWrapped(AreaCircleFact f1, AreaCircleFact f2)
        {
            if (f1.Cid1 == f2.Cid1)
                return true;
            CircleFact c1f1 = (CircleFact)_Facts[f1.Cid1];
            CircleFact c1f2 = (CircleFact)_Facts[f2.Cid1];
    
            return (c1f1.Equivalent(c1f2) && f1.A == f2.A);
        }
    }
    
    
    /// <summary>
    /// The volume of a cone A  defined by a base area  <see cref="CircleFact">CircleFact</see>, an apex <see cref="PointFact">PointFact</see> and the volume as float
    /// </summary>
    public class ConeVolumeFact : FactWrappedCRTP<ConeVolumeFact>
    {
        ///  <summary> a <see cref="CircleFact">CircleFact</see> describing the base area </summary>
        public string Cid1;
        ///  <summary> a <see cref="PointFact">PointFact</see> describing the apex point  </summary>
        public string Pid1;
        ///  <summary> the volume of the cone as a float </summary>
        public float vol;
    
        /// <summary> \copydoc Fact.Fact </summary>
        public ConeVolumeFact() : base()
        {
            this.Cid1 = null;
            this.Pid1 = null;
            this.vol = 0.0f;
    
        }
    
        /// <summary>
        /// Copies <paramref name="fact"/> by initiating new MMT %Fact.
        /// </summary>
        /// <param name="fact">Fact to be copied</param>
        /// <param name="old_to_new"><c>Dictionary</c> mapping <paramref name="fact"/>.<see cref="getDependentFactIds"/> in <paramref name="fact"/>.<see cref="Fact._Facts"/> to corresponding <see cref="Fact.Id"/> in <paramref name="organizer"/> </param>
        /// <param name="organizer">sets <see cref="_Facts"/></param>
        public ConeVolumeFact(ConeVolumeFact fact, Dictionary<string, string> old_to_new, FactOrganizer organizer) : base(fact, organizer)
        {
            init(old_to_new[fact.Cid1], old_to_new[fact.Pid1], fact.vol);
        }
    
        /// <summary>
        /// Standard Constructor
        /// </summary>
        /// <param name="cid1">sets <see cref="Cid1"/></param>
        /// <param name="pid1">sets <see cref="Pid1"/></param>
        /// <param name="vol">sets <see cref="vol"/></param>
        /// <param name="organizer">sets <see cref="Fact._Facts"/></param>
        public ConeVolumeFact(string cid1,string pid1, float vol, FactOrganizer organizer) : base(organizer)
        {
            init(cid1,pid1,vol);
        }
    
        /// <summary>
    
        /// Initiates <see cref="Cid1"/>, <see cref="Pid1"/>, <see cref="vol"/>,  <see cref="Fact._URI"/> and creates MMT %Fact Server-Side
    
        /// </summary>
        /// <param name="cid1">sets <see cref="Cid1"/></param>
        /// <param name="pid1">sets <see cref="Pid1"/></param>
        /// <param name="vol">sets <see cref="vol"/></param>
        private void init(string cid1,string pid1, float vol)
        {
            this.Cid1 = cid1;
            this.Pid1 = pid1;
    
            CircleFact cf1 = _Facts[cid1] as CircleFact;
            PointFact pf1 = _Facts[pid1] as PointFact;
            this.vol = vol;
    
    
            MMTDeclaration mmtDecl;
            string c1URI = cf1.Id;
            string p1URI = pf1.Id;
    
    
            mmtDecl = generateMMTDeclaration(c1URI, p1URI, vol);
    
            AddFactResponse.sendAdd(mmtDecl, out this._URI);
        }
    
        /// <summary>
        /// Bypasses initialization of new MMT %Fact by using existend URI, _which is not checked for existence_.
        /// </summary>
    
        /// <param name="Cid1">sets <see cref="Cid1"/></param>
        /// <param name="Pid1">sets <see cref="Pid1"/></param>
        /// <param name="volume">sets <see cref="vol"/></param>
    
        /// <param name="backendURI">MMT URI</param>
        /// <param name="organizer">sets <see cref="Fact._Facts"/></param>
        public ConeVolumeFact(string Cid1,string Pid1, float volume,  string backendURI, FactOrganizer organizer) : base(organizer)
        {
            this.Cid1 = Cid1;
            this.Pid1 = Pid1;
            this.vol = volume;
    
            this._URI = backendURI;
            _ = this.Label;
        }
    
        /// \copydoc Fact.parseFact(Scroll.ScrollFact)
        public new static ConeVolumeFact parseFact(Scroll.ScrollFact fact)
        {
            string uri = fact.@ref.uri;
    
            if (((Scroll.ScrollValueFact)fact).lhs == null)
                return null;
    
            string CircleUri = ((OMS)((OMA)((OMA)((Scroll.ScrollValueFact)fact).lhs).arguments[0]).arguments[0]).uri;
            string PointUri = ((OMS)((OMA)((OMA)((Scroll.ScrollValueFact)fact).lhs).arguments[0]).arguments[1]).uri;
            float volume = 0.0f;
            if( (((Scroll.ScrollValueFact)fact).value) !=null   )
                volume =  ((OMF) ((Scroll.ScrollValueFact)fact).value).f ;
    
            if (StageStatic.stage.factState.ContainsKey(CircleUri)&& StageStatic.stage.factState.ContainsKey(PointUri))
    
                return new ConeVolumeFact(CircleUri,PointUri,volume, uri, StageStatic.stage.factState);
    
            else    //If dependent facts do not exist return null
                return null;
        }
    
        /// \copydoc Fact.generateLabel
        protected override string generateLabel()
        {
            return "V(" + _Facts[Cid1].Label +"," + _Facts[Pid1].Label+")";
        }
    
        /// <summary>
        /// Constructs struct for not-right-angled MMT %Fact <see cref="AddFactResponse"/>
        /// </summary>
        /// <param name="c1URI"> Uri for <see cref="Cid1"/></param>
        /// <param name="p1URI"> Uri for <see cref="Pid1"/></param>
        /// <param name="val"> <see cref="vol"/></param>
        /// <returns>struct for <see cref="AddFactResponse"/></returns>
        private MMTDeclaration generateMMTDeclaration(string c1URI, string p1URI, float val)
        {
            MMTTerm lhs =
                new OMA(
                    new OMS(MMTURIs.VolumeCone),
    
                    new List<MMTTerm> {
                        new OMA(new OMS(MMTURIs.ConeOfCircleApex),
                            new List<MMTTerm> {
                                new OMS(c1URI),
                                new OMS(p1URI),
                             }
                        ),
                    }
                );
    
            MMTTerm valueTp = new OMS(MMTURIs.RealLit);
            MMTTerm value = new OMF(val);
    
            return new MMTValueDeclaration(this.Label, lhs, valueTp, value);
        }
    
        /// \copydoc Fact.hasDependentFacts
        public override Boolean hasDependentFacts()
        {
            return true;
        }
    
        /// \copydoc Fact.getDependentFactIds
        public override string[] getDependentFactIds()
        {
            return new string[] { Cid1, Pid1 };
        }
    
        /// \copydoc Fact.instantiateDisplay(GameObject, Transform)
        public override GameObject instantiateDisplay(GameObject prefab, Transform transform)
        {
            var obj = GameObject.Instantiate(prefab, Vector3.zero, Quaternion.identity, transform);
            obj.transform.GetChild(0).gameObject.GetComponent<TextMeshProUGUI>().text =  _Facts[this.Cid1].Label+ _Facts[this.Pid1].Label;
            obj.GetComponent<FactWrapper>().fact = this;
    
            return obj;
        }
    
        /// \copydoc Fact.GetHashCode
        /// uhhh is this a problem?
        public override int GetHashCode()
        {
            return this.Cid1.GetHashCode()^this.Pid1.GetHashCode();
        }
    
        /// \copydoc Fact.Equivalent(Fact, Fact)
        protected override bool EquivalentWrapped(ConeVolumeFact f1, ConeVolumeFact f2)
        {
            if (f1.Cid1 == f2.Cid1 && f1.Pid1 == f2.Pid1)
                return true;
    
            CircleFact c1f1 = (CircleFact)_Facts[f1.Cid1];
            CircleFact c1f2 = (CircleFact)_Facts[f2.Cid1];
    
            PointFact p1f1 = (PointFact)_Facts[f1.Pid1];
            PointFact p1f2 = (PointFact)_Facts[f2.Pid1];
    
            return (c1f1.Equivalent(c1f2)&& p1f1.Equivalent(p1f2) && f1.vol== f2.vol );
    
        }
    }
    
    
    /// <summary>
    /// The fact that the plane of a <see cref="CircleFact">CircleFact</see> and the line <see cref="RayFact>RayFact</see> are orthogonal
    /// </summary>
    public class OrthogonalCircleLineFact : FactWrappedCRTP<OrthogonalCircleLineFact>
    {
        ///  <summary> a <see cref="CircleFact">CircleFact</see> describing the base area </summary>
        public string Cid1;
        ///  <summary> a <see cref="RayFact">Rayfact</see> describing the line </summary>
        public string Lid1;
      
    
        /// <summary> \copydoc Fact.Fact </summary>
        public OrthogonalCircleLineFact() : base()
        {
            this.Cid1 = null;
            this.Lid1 = null;
    
        }
    
        /// <summary>
        /// Copies <paramref name="fact"/> by initiating new MMT %Fact.
        /// </summary>
        /// <param name="fact">Fact to be copied</param>
        /// <param name="old_to_new"><c>Dictionary</c> mapping <paramref name="fact"/>.<see cref="getDependentFactIds"/> in <paramref name="fact"/>.<see cref="Fact._Facts"/> to corresponding <see cref="Fact.Id"/> in <paramref name="organizer"/> </param>
        /// <param name="organizer">sets <see cref="_Facts"/></param>
        public OrthogonalCircleLineFact(OrthogonalCircleLineFact fact, Dictionary<string, string> old_to_new, FactOrganizer organizer) : base(fact, organizer)
        {
            init(old_to_new[fact.Cid1], old_to_new[fact.Lid1]);
        }
    
        /// <summary>
        /// Standard Constructor
        /// </summary>
        /// <param name="cid1">sets <see cref="Cid1"/></param>
    
        /// <param name="lid1">sets <see cref="Lid1"/></param>
    
        /// <param name="organizer">sets <see cref="Fact._Facts"/></param>
        public OrthogonalCircleLineFact(string cid1, string lid1, FactOrganizer organizer) : base(organizer)
        {
            init(cid1, lid1);
        }
    
        /// <summary>
        /// Initiates <see cref="Pid1"/>, <see cref="Pid2"/>, <see cref="Pid3"/>, <see cref="is_right_angle"/>, <see cref="Fact._URI"/> and creates MMT %Fact Server-Side
        /// </summary>
        /// <param name="cid1">sets <see cref="Cid1"/></param>
    
        /// <param name="lid1">sets <see cref="Lid1"/></param>
    
        private void init(string cid1, string lid1)
        {
            this.Cid1 = cid1;
            this.Lid1 = lid1;
    
            CircleFact cf1 = _Facts[cid1] as CircleFact;
            RayFact lf1 = _Facts[lid1] as RayFact;
    
    
            MMTDeclaration mmtDecl;
            string c1URI = cf1.Id;
            string l1URI = lf1.Id;
    
    
            mmtDecl = generateMMTDeclaration(c1URI, l1URI);
    
            AddFactResponse.sendAdd(mmtDecl, out this._URI);
        }
    
        /// <summary>
        /// Bypasses initialization of new MMT %Fact by using existend URI, _which is not checked for existence_.
        /// </summary>
    
        /// <param name="Cid1">sets <see cref="Cid1"/></param>
        /// <param name="Lid1">sets <see cref="Lid1"/></param>
    
        /// <param name="backendURI">MMT URI</param>
        /// <param name="organizer">sets <see cref="Fact._Facts"/></param>
        public OrthogonalCircleLineFact(string Cid1, string Lid1,  string backendURI, FactOrganizer organizer) : base(organizer)
        {
            this.Cid1 = Cid1;
            this.Lid1 = Lid1;
    
            this._URI = backendURI;
            _ = this.Label;
        }
    
        /// \copydoc Fact.parseFact(Scroll.ScrollFact)
        public new static OrthogonalCircleLineFact parseFact(Scroll.ScrollFact fact)
        {
            OMA tp = (OMA)((Scroll.ScrollSymbolFact)fact).tp;
            if (tp == null)
                return null;
    
            string uri = fact.@ref.uri;
    
            string CircleUri = ((OMS)((OMA)((OMA)((Scroll.ScrollSymbolFact)fact).tp).arguments[0]).arguments[0]).uri;
            string LineUri = ((OMS)((OMA)((OMA)((Scroll.ScrollSymbolFact)fact).tp).arguments[0]).arguments[1]).uri;
    
            if (StageStatic.stage.factState.ContainsKey(CircleUri)
             && StageStatic.stage.factState.ContainsKey(LineUri))
    
                return new OrthogonalCircleLineFact(CircleUri, LineUri, uri, StageStatic.stage.factState);
    
            else    //If dependent facts do not exist return null
                return null;
        }
    
        /// \copydoc Fact.generateLabel
        protected override string generateLabel()
        {
            return   _Facts[Cid1].Label + "⊥" + _Facts[Lid1].Label;
        }
    
        /// <summary>
        /// Constructs struct for not-right-angled MMT %Fact <see cref="AddFactResponse"/>
        /// </summary>
        /// <param name="c1URI"> Uri for <see cref="Cid1"/></param>
        /// <param name="l1URI"> Uri for <see cref="Lid1"/></param>
        /// <returns>struct for <see cref="AddFactResponse"/></returns>
        private MMTDeclaration generateMMTDeclaration(string c1URI, string l1URI)
        {
            List<MMTTerm> innerArguments = new List<MMTTerm>
            {
                new OMS(c1URI),
                new OMS(l1URI)
            };
    
            List<MMTTerm> outerArguments = new List<MMTTerm>
            {
                new OMA(new OMS(MMTURIs.OrthoCircleLine), innerArguments)
            };
            MMTTerm tp = new OMA(new OMS(MMTURIs.Ded), outerArguments);
            MMTTerm df = null;
    
            return new MMTSymbolDeclaration(this.Label, tp, df);
        }
    
        /// \copydoc Fact.hasDependentFacts
        public override Boolean hasDependentFacts()
        {
            return true;
        }
    
        /// \copydoc Fact.getDependentFactIds
        public override string[] getDependentFactIds()
        {
            return new string[] { Cid1, Lid1 };
        }
    
        /// \copydoc Fact.instantiateDisplay(GameObject, Transform)
        public override GameObject instantiateDisplay(GameObject prefab, Transform transform)
        {
            var obj = GameObject.Instantiate(prefab, Vector3.zero, Quaternion.identity, transform);
            obj.transform.GetChild(0).gameObject.GetComponent<TextMeshProUGUI>().text = _Facts[this.Cid1].Label;
            obj.transform.GetChild(1).gameObject.GetComponent<TextMeshProUGUI>().text = _Facts[this.Lid1].Label;
    
            obj.GetComponent<FactWrapper>().fact = this;
            return obj;
        }
    
        /// \copydoc Fact.GetHashCode
        /// uhhh is this a problem?
        public override int GetHashCode()
        {
            return this.Cid1.GetHashCode() ^ this.Lid1.GetHashCode();
        }
    
        /// \copydoc Fact.Equivalent(Fact, Fact)
        protected override bool EquivalentWrapped(OrthogonalCircleLineFact f1, OrthogonalCircleLineFact f2)
        {
            if (f1.Cid1 == f2.Cid1 && f1.Lid1 == f2.Lid1)
                return true;
    
            CircleFact c1f1 = (CircleFact)_Facts[f1.Cid1];
            CircleFact c1f2 = (CircleFact)_Facts[f2.Cid1];
    
            RayFact l1f1 = (RayFact)_Facts[f1.Lid1];
            RayFact l1f2 = (RayFact)_Facts[f2.Lid1];
    
            return (c1f1.Equivalent(c1f2) && l1f1.Equivalent(l1f2));
    
        }
    }
    
    /// <summary>
    /// The volume of a cone A  defined by a base area  <see cref="CircleFact">CircleFact</see>, a top area <see cref="CircleFact">CircleFact</see> and the volume as float
    /// </summary>
    public class TruncatedConeVolumeFact : FactWrappedCRTP<TruncatedConeVolumeFact>
    {
        ///  <summary> a <see cref="CircleFact">CircleFact</see> describing the base area </summary>
        public string Cid1;
    
        ///  <summary> a <see cref="CircleFact">CircleFact</see> describing the top area  </summary>
    
        ///  <summary> the volume of Truncated the cone as a float </summary>
    
        /// <summary> a proof that both circles have not the same size </summary>
        public string unequalCirclesProof;
    
        ///  <summary> OMA proof that the two circles are parallel  </summary>
        public OMA proof;
    
    
        /// <summary> \copydoc Fact.Fact </summary>
        public TruncatedConeVolumeFact() : base()
        {
            this.Cid1 = null;